<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[a wandersick’s Tech Notes - Medium]]></title>
        <description><![CDATA[IT techniques in a different way; how-to articles and free utilities written by wandersick - Medium]]></description>
        <link>https://medium.com/wandersick?source=rss----ef8444397f30---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>a wandersick’s Tech Notes - Medium</title>
            <link>https://medium.com/wandersick?source=rss----ef8444397f30---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 12:57:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/wandersick" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Quick Ansible Overview — Remediate Host Configuration Drift (Infrastructure-as-Code)]]></title>
            <link>https://medium.com/wandersick/quick-ansible-overview-remediate-host-configuration-drift-infrastructure-as-code-5fbd50f2bb38?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/5fbd50f2bb38</guid>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[security-compliance]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Tue, 22 Sep 2020 04:26:41 GMT</pubDate>
            <atom:updated>2022-05-07T05:13:24.223Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Quick Ansible Overview — Remediate Host Configuration Drift (Infrastructure-as-Code)</h3><p>This introductory article is about Infrastructure-as-Code (IaC) and a major player of which, <a href="https://www.ansible.com/">Ansible</a>, its concepts — control node, managed host, inventory, playbook and modules — along with a quick example using an Ansible command to remediate configuration drift of managed computers, so that a specified service on them is running in its desired state.</p><h3>Infrastructure-as-Code</h3><blockquote><em>DevOps is not a Goal, but a never-ending process of continual improvement. — </em><a href="https://continuousdelivery.com/about/"><em>Jez Humble</em></a></blockquote><p>It is the era of DevOps, where development (Dev) and operation (Ops) are converged and streamlined for the benefit of the business. On the infrastructure side, it is also desired that managing hosts (mostly servers and workstations) be done in a modern way to fit in the DevOps mindset where everything is defined as code to allow for agility which enables continual improvement.</p><p>Comes Infrastructure-as-Code automation engines, available as command-line tools which can be leveraged for infrastructure compliance remediation. Such things might sound difficult to be done in the past, but thanks to the advance in technology, the complexity is hidden by automation engines such as Ansible.</p><h3>Ansible</h3><blockquote><em>Automation is good, so long as you know exactly where to put the machine. — </em><a href="https://en.wikipedia.org/wiki/Eliyahu_M._Goldratt"><em>Eliyahu Goldratt</em></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*SZ5FKh6xqMPOD1rY" /></figure><p><a href="https://en.wikipedia.org/wiki/Ansible_(software)">Ansible</a> is an open-source agentless configuration management tool from Red Hat which treats infrastructure as code. It can prevent configuration drift by maintaining the desired state, e.g. ensuring operating system firewall is running, by remediating security and compliance issues according to Ansible playbooks of rules specified against an Ansible inventory file of computers.</p><h3>How Ansible Works</h3><p>Operating Ansible commonly involves developing Ansible playbooks in YAML format, as well as writing inventory files in INI format. They are simpler than other syntax file formats such as JSON (which is also supported by Ansible), and are (arguably) more friendly to the less technically-inclined. These will be used in our quick example.</p><h4>Some Ansible Terminology</h4><ul><li><em>Inventory</em> — an INI file (e.g. inventory.ini) where a list of <em>managed hosts</em> (also known as <em>managed nodes</em>) are defined. These may be computers a system administrator would like to manage</li><li><em>Playbook</em> — a YAML file (or JSON) where rules are defined, e.g. rule-book.yml</li></ul><p>A computer with <a href="https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html">Ansible installed</a>, the <em>control node</em>, can then execute the ansible-playbook command, specifying the inventory and playbook via its parameters, e.g. ansible-playbook -i inventory.ini rule-book.yml to check or remediate any compliance drift found in the managed hosts.</p><h4>Ansible Host Inventory — inventory.ini</h4><p>This is an example of an inventory which shows two Linux servers.</p><p>Specify two Linux servers named LNXSVR01 and LNXSVR02 (which are used below as an example of managed hosts) in inventory.ini:</p><pre>LNXSVR01<br>LNXSVR02</pre><h4>Ansible Playbook — rule-book.yml</h4><p>This is an example of a playbook which shows firewall must be started.</p><p>Perform compliance checking to ensure firewall service is running on all hosts defined in the inventory by creating the playbook, e.g. rule-book.yml as below:</p><pre>---<br>- hosts: all # Apply to all hosts in the inventory file<br>  remote_user: root<br>  tasks:<br>    - name: ensure firewall service is running<br>      service:<br>        name: &#39;{{ item }}&#39;<br>        state: started<br>        enabled: yes<br>      with_items:<br>        - firewalld # Add more services to this list as required</pre><p>Although the above example merely shows checking or remediating a single item, when rules like this are combined together according to system hardening guides such as the ones published by <a href="https://medium.com/wandersick/quick-windows-hardening-with-chef-infrastructure-as-code-aa8095a64cfe">Center for Internet Security</a> (CIS), they ensure computers are compliant with industry standards.</p><h4>Ansible Command</h4><p>Putting it together, run Ansible playbook rule-book.yml against computer inventory inventory.ini with superuser privilege via --sudo (or --become) parameter:</p><pre>$ ansible-playbook -i inventory.ini rule-book.yml --sudo</pre><p>The command can be fired up manually or via a scheduled cron job.</p><h4>Ansible Checking and Remediation Results</h4><p>LNXSVR01, whose firewall was not running, becomes compliant after the Ansible playbook execution. On the other hand, LNXSVR02, whose firewall was already running, was idempotent*:</p><pre>PLAY [all] ***************************************************<br>TASK [Gathering Facts] ***************************************<br>ok: [LNXSVR02]<br>ok: [LNXSVR01]<br>TASK [Ensure firewall service is running] ***<br>ok: [LNXSVR02] =&gt; (item=firewalld)<br>changed: [LNXSVR01] =&gt; (item=firewalld)</pre><pre>PLAY RECAP ***************************************************<br>LNXSVR01      : ok=4    changed=1    unreachable=0    failed=0<br>LNXSVR02      : ok=4    changed=0    unreachable=0    failed=0</pre><p>*Idempotent in this context means only execute when configuration has drifted; otherwise, no action would be performed no matter how many times the command has been run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4vROmrxhDgm9HS2L" /></figure><h3>Extending Capability with Community Modules</h3><p>Ansible, being the most popular configuration management project on <a href="https://github.com/ansible/ansible">GitHub</a> and being in the top-10 chart there for many years, has an active community developing modules to extend capabilities of it.</p><p>For example, due to Windows previously lacking a native software package manager (e.g. yum on Red Hat or apt-get on Ubuntu Linux), Chocolatey, the most popular third-party Windows package manager, was born and can be used via win_chocolatey module in Ansible, which is one of the modules maintained by the community.</p><p>Taking <a href="https://medium.com/wandersick/aerozoom-a-smooth-wheel-zooming-mouse-enhancing-panel-cd2bdc5e6489">AeroZoom</a> as an example of Windows software on <a href="https://chocolatey.org/packages/aerozoom">Chocolatey</a>, which is a keyboard-free screen magnifier freeware application created and <a href="https://medium.com/wandersick/how-to-create-a-silent-installer-with-autohotkey-and-publish-it-on-chocolatey-8e3a9cf6da70">submitted by me to the Chocolatey community repository</a>. Below, AeroZoom acts as a required item for compliance checking.</p><p>A playbook which performs compliance checking to ensure AeroZoom is installed would be like this:</p><pre>---<br>  tasks:<br>    - name: ensure AeroZoom Windows application is installed<br>      win_chocolatey:<br>        name: AeroZoom<br>        state: present</pre><h3>Further from Here</h3><p>Ansible is truly a powerful configuration management tool used by DevOps engineers. Being a simple command-line tool, it does not come with a graphical user interface. For those who need it, a separate web-based application, <a href="https://www.ansible.com/products/tower">Red Hat Ansible Towers</a> (or <a href="https://github.com/ansible/awx">AWX</a>, the open-source upstream variant of which), can be deployed.</p><p>Ansible can manage both <a href="https://docs.ansible.com/ansible/latest/user_guide/index.html">Linux</a> and <a href="https://docs.ansible.com/ansible/latest/user_guide/windows.html">Windows</a> machines. However, the control node of Ansible is so far only available on Unix-esque platforms such as Linux, which is less approachable to IT professionals who may be more used to the Windows platform. Some time ago, Microsoft has included <a href="https://docs.microsoft.com/en-us/windows/wsl/">Windows Subsystem for Linux</a> (WSL) in Windows 10 which can install and run Ansible. There are limitations last time I checked (such as not supporting cron which many people use to trigger Ansible), but once it matures, who knows? It could someday totally replace the need for a separate virtual machine or docker instance merely to run Ansible on Windows.</p><p>All in all, Ansible has high potential being a great lightweight (agentless) tool which is handy e.g. for sysadmins to ensure system compliance, DevOps engineers to configure operating systems after they are provisioned, and so much more!</p><p>If this article helps you get started with Ansible, feel free to let me know. In future, I may explore more aspects of Ansible where I find useful or interesting. Stay tuned! 😊</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2020/09/quick-ansible-overview.html"><em>https://tech.wandersick.com</em></a><em> on September 22, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fbd50f2bb38" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/quick-ansible-overview-remediate-host-configuration-drift-infrastructure-as-code-5fbd50f2bb38">Quick Ansible Overview — Remediate Host Configuration Drift (Infrastructure-as-Code)</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Folder Template Provisioner]]></title>
            <link>https://medium.com/wandersick/folder-template-provisioner-3f51a9615e06?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/3f51a9615e06</guid>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[batch-script]]></category>
            <category><![CDATA[scripting]]></category>
            <category><![CDATA[command-line]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Sun, 13 Sep 2020 13:18:12 GMT</pubDate>
            <atom:updated>2026-10-11T13:25:13.395Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>For file server admins, this Windows batch script provisions (copies) new folders with exact permissions and content from a specified existing folder (template) based on the information inputted by a user via its command-line interface. It hopes to reduce the burden of Windows admins by handling over the task of folder provisioning to users.</p><p>It uses robocopy /MIR /COPYALL /ZB to solve the problem where folders copied using Windows Explorer (a.k.a. File Explorer) may not retain unique permissions and inherit permissions from parent folder.</p><p><strong>[</strong><a href="https://tech.wandersick.com/2020/09/folder-template-provisioner.html#download"><strong>Go to Download</strong></a><strong>]</strong></p><h3>Features</h3><ul><li>Accept input from user<br>- First name and last name (feel free to modify them for other use cases where appropriate)</li><li>Copy a new folder using specified template folder retaining exact permissions and content using robocopy /MIR /COPYALL named in LASTNAME, First Name format according to user input</li><li>Support of network-shared folder in UNC form (\\...) is available<br>- In other words, for drives mapped using a drive letters, they are supported by specifying the UNC path within this script. See <a href="https://tech.wandersick.com/2020/09/folder-template-provisioner.html#user-content-step-by-step---how-to-provision-a-new-folder">How to Set up the Scripts</a> section<br>- To test or use this script for non-network cases (local drives) from v1.2 and on, specify \\127.0.0.1\... or \\localhost\... where required</li><li>Support of admin users with UAC enabled<br>- Automatically elevate the script to run it as admin if UAC (User Account Control) is enabled but admin rights are unavailable. This requires an optional script in the same folder (_elevate.vbs)</li><li>Partial support of non-admin users using runas /savecred (built-in)<br>- If users do not have admin rights, _runasAdmin.bat (included optional script) can be edited to leverage runas /savecred to run FolderTemplateProvisioner.bat (main script) as admin without entering admin credentials<br>- Also refer to <a href="https://tech.wandersick.com/2020/09/folder-template-provisioner.html#user-content-security-note">Security Notes</a> on the risk involved naturally with runas /savecred</li><li>Error checking and messages available<br>- Windows Script Host is unavailable (for the UAC elevation VBScript)<br>- Admin rights are unavailable<br>- Invalid first name / last name<br>- File copy (folder template provisioning) failure and the robocopy return code</li><li>Confirmation prompt<br>- Names inputted by user are shown again for review and confirmation, requesting user to confirm there is no existing files</li><li>Logging<br>- A robocopy log file is saved and appended to %Temp%\FolderCreator.log. As this is not meant to be permanent, it can get deleted by system shortly afterwards</li></ul><h3>Requirements</h3><ol><li>Windows OS with robocopy</li><li>admin rights (with or without UAC)</li><li>Non-admin rights (partially supported with an optional setup on _runasAdmin.bat)</li></ol><h3>Script Filenames</h3><ol><li>FolderTemplateProvisioner.bat (main script)</li><li>_elevate.vbs (optional, for admin users with UAC turned on, trigger UAC elevation prompt)</li><li>_runasAdmin.bat (optional, for non-admin users to leverage runas /savecred to run as admin)</li></ol><h3>Folder Hierarchy</h3><pre>│ FolderTemplateProvisioner.bat // main script<br>│ _elevate.vbs // (optional) for admin users<br>│              // with UAC enabled to auto-trigger UAC prompt <br>│ _runasAdmin.bat // (optional) for non-admins<br>│                 // to run as admin without admin credentials <br>│<br>├───ZZ IT_do not use\01 Template Folder <br>│            // Template folder (this can be a sub-folder)<br>│            // with folders/files of set permissions to copy<br>│<br>├───A // Last names beginning with an &quot;A&quot;<br>│   │───LASTNAME, Firstname 1  // Each copied folder is named<br>│   │───LASTNAME, Firstname 2  // this way according to names<br>│   │                       .  // inputted by user with <br>│   │                       .  // sub-folders and files <br>│   │                       .  // retaining specific permissions<br>│   └───LASTNAME, Firstname n<br>│<br>├───B<br>├───C<br>│   .<br>│   .   // created folders are placed in folders<br>│   .   // according to initials from user input<br>└───Z</pre><h3>Step by Step — How to Set up the Scripts</h3><p><strong>Step 1</strong>. Skip this step and go straight to step 2 if users have admin rights. This is for cases where users executing the script do not have admin rights.</p><p>Edit the UNC path in _runasAdmin.bat setting it to the the script path, e.g. \\serverName\d$\Human Resources\01_Personnel-Files\FolderTemplateProvisioner.bat</p><ul><li>It must be a UNC path starting with “\” instead of a drive letter</li></ul><p>Edit /u:DOMAIN\username by changing DOMAIN to the Active Directory domain name (NETBIOS name), and the username as the admin user. For non-domain (workgroup) scenarios, DOMAIN can be skipped by removing DOMAIN\</p><ul><li>If a non-domain account is specified, runas command still requires the PC to be connected to domain. This appears to be a limitation of runas</li><li>User Account Control (UAC) has to be disabled, i.e. setting EnableLUA to 0 under Windows registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System, or the target runas user is the <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-account-control-admin-approval-mode-for-the-built-in-administrator-account">built-in domain or local Administrator account</a> which is unaffected by UA</li><li>Kindly ensure the <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-account-control-admin-approval-mode-for-the-built-in-administrator-account">group policy</a> User Account Control: Use Admin Approval Mode for the built-in Administrator account is undefined or disabled; otherwise, it may prevent the built-in administrator account from bypassing UAC limitations (in case this approach is chosen instead of disabling UAC)</li></ul><p>Before _runasAdmin.bat (or the runas /savecred ... command) can be run by non-admin users, it needs to be <strong>run once on PCs of users who need to use Folder Template Provisioner</strong> without admin credentials. (The first run involves prompting for admin credentials where an admin needs to be there to input admin password once)</p><p><strong>Step 2</strong>. Edit encPath variable at the upper area of FolderTemplateProvisioner.bat script by setting it to the network folder containing the script, e.g. \\serverName\d$\Human Resources\01_Personnel-Files</p><p><strong>Step 3</strong>. Edit templateName variable at the upper area of FolderTemplateProvisioner.bat script by setting it to the folder acting as the template, e.g. ZZ IT_do not use\01 Template Folder, with required files and permissions inside</p><p><strong>Step 4</strong>. Place all scripts (FolderTemplateProvisioner.bat, optionally _elevate.vbs and _runasAdmin.bat) inside a folder containing A,B...Z sub-folders, sitting aside. The A-Z folders contains the template folder and provisioned folders named LASTNAME, Firstname copied by the script from the template folder</p><h3>Step by Step — How to Provision a New Folder</h3><p><strong>Step 1</strong>. Double-click FolderTemplateProvisioner.bat and follow on-screen instructions</p><ul><li>For non-admin users, they should run _runasAdmin.bat instead</li></ul><p><strong>Step 2</strong>. Input last name and first name</p><p><strong>Step 3</strong>. Review the input</p><p><strong>Step 4</strong>. Wait for robocopy file copy (folder template provisioning)</p><p><strong>Step 5</strong>. Verify the created folder</p><h3>Screenshots — Provisioning a New Folder with the Script</h3><p>A. Run FolderTemplateProvisioner.bat</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/0*sPmNuBBmfR6fR33W.png" /></figure><p><strong>Note</strong>: non-admins should run _runasAdmin.bat instead, available since v1.2</p><p>For admins with UAC enabled, a UAC elevation prompt (like the one below) is displayed automatically, provided that an optional _elevate.vbs exists in the same folder. (_elevate.vbs should not be run directly. Instead, run FolderTemplateProvisioner.bat)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/0*UaW4_Tcw1sBWPS88.png" /></figure><p>B. Input first name and last name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*eZRYJKHRSWJgsGEn.png" /></figure><p>C. Review and confirm input</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*5MgF1Itqctpmfh4V.png" /></figure><p>Note: Since v1.2, users would receive a message requesting them to ensure no folder of the same name exists in destination before continuing; otherwise, content would be overwritten.</p><p>D. Robocopy provisions new folder from folder template with exact content and permissions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/0*knn9VytPJjEpcvRo.png" /></figure><p><strong>Note</strong>: Since v1.2, users would receive a message at the end recommending them to verify the created folder at target location.</p><h3>Screenshots — Error Messages</h3><p>A. Name inputted by user is invalid</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/0*FbpE4kOfJOVyc9FM.png" /></figure><p>B. Robocopy error ends with a return code presented to user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*y2E33BIiqmgpdArO.png" /></figure><p>C. No admin rights are detected, while UAC is off and/or the optional _elevate.vbs is not in the same folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*rA3Nxg1UFFqgzPqE.png" /></figure><p>Other error messages include:</p><ul><li>Windows Script Host is unavailable (for the UAC elevation VBScript)</li></ul><h3>Security Note</h3><p>This part can be skipped if you don’t let users use this set of scripts without admin rights.</p><p>As with most technology that enables convenience, kindly beware of the natural security risk involved with _runasAdmin.bat, i.e. runas /savecred. In this case, a non-admin user would be able to use the runas /savecred command to run any command as an admin without entering a password. Please do understand such risk involved if you still would like to go ahead with the non-admin approach to using this script.</p><h3>Another Possible Approach for Non-Admin</h3><p>This part can be skipped. It is only for enthusiasts wishing to modify this script to run it as non-admin without even using _runasAdmin.bat or runas /savecred.</p><ul><li>Admins rights or the _runasAdmin.bat (runas /savecred) workaround for non-admin are already supported by this script. The below may not be suitable to all cases and hence, it is left as an idea for enthusiasts to attempt should it be desired.</li></ul><p>Several prerequisites and/or adjustments would be required (<strong>experimental</strong>):</p><ol><li>Remove /ZB parameter from the robocopy command in the script (note: /ZB uses backup operator rights to copy if permission is unavailable. This requires admin rights)</li><li>Change /COPYALL to /COPY:DATSO (this removes the &#39;manage auditing&#39; part which requires admin rights)</li><li>The template folder should include the desired non-admin user as <strong>owner </strong>with <strong>full </strong>permission in the underlying folders</li><li>Remove lines in this script between attrib &gt;nul 2&gt;&amp;1 and :skipAdminCheckSubsequent</li></ol><p><strong>Note</strong>: The above is approach is experimental, hence unsupported.</p><h3>Download</h3><p>⭐ Download Folder Template Provisioner on its <a href="https://tech.wandersick.com/2020/09/folder-template-provisioner.html#download">homepage</a>.</p><h3>Release History</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jzNgV8XHWmOH5lEadZoMKg.png" /></figure><p>Hope this article or the tool is useful to you. 😊</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2020/09/folder-template-provisioner.html"><em>https://tech.wandersick.com</em></a><em> on Sep 09, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f51a9615e06" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/folder-template-provisioner-3f51a9615e06">Folder Template Provisioner</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate Windows Group Member Update via CSV File or LDAP Query with PowerShell]]></title>
            <link>https://medium.com/wandersick/automate-windows-group-member-update-via-csv-file-or-ldap-query-with-powershell-6db1b2de52d5?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/6db1b2de52d5</guid>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[windows-server]]></category>
            <category><![CDATA[powershell]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Sun, 14 Jun 2020 09:38:12 GMT</pubDate>
            <atom:updated>2026-10-11T13:25:28.760Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Designed for Active Directory (AD) admins, this PowerShell script ws-dynamic-group automates the addition or removal of group members in a Windows local or AD domain group based on content in a CSV file or an LDAP query, turning a static group into a dynamic one.</p><p>Preventive features such as setting a threshold to avoid deletion of a massive number of group members by mistake, logging and mail alerts are also available.</p><p><strong>[Go to </strong><a href="https://tech.wandersick.com/2020/06/automate-windows-group-member-update-via-csv-or-ldap-with-powershell.html#download"><strong>Download</strong></a><strong>]</strong></p><h3>List of Features</h3><ul><li>Keeping track of a specified CSV file for adding or removing group members in a local/domain group by comparing the group members of the file with group members on a system. (For scheduling, add it to a task using the built-in Windows Task Scheduler)<br>– If group members exist in CSV file but not in system, add the usernames<br>– If group members exist in system but not in CSV file, delete the usernames</li><li>Specify usernames of group members dynamically or statically<br>– Dynamic mode: the CSV input file can be created dynamically according to an LDAP query (specified in the script) from a live Active Directory domain<br>– Static mode: the input CSV file can also be pre-created (at a location and file name defined in the script)</li><li>Settings can be supplied via command-line switches or by editing the script<br>– For example, the group name can be specified via customGroupName in the upper <a href="#5f98">variable section within the script</a> or by running the script with -groupName command-line switch as in ws-dynamic-group.ps1 -groupName managers</li><li>Apply the modifications (addition/deletion of group member) to the system either locally (workgroup) or on a domain controller (Active Directory)<br>– There is support for both local (workgroup) and domain (Active Directory) environments. (Refer to <a href="#5f98">Script Settings</a> section)</li><li>Skip group member deletion if there is a mistake on the source side (e.g. content in CSV file is wrong) when a configurable threshold is reached<br>– Email alerts can be additionally configured to report on the event of skipping group member deletion due to reaching a specified threshold, so that admins can take action accordingly</li><li>There are 3 types of logging supported<br>– Lists of group members “before” and “after” running the script are saved separately for each run under the directory 03_Done (The script backs up all users beforehand and afterwards to facilitate troubleshooting and comparison in times of need)<br>– Console output logging (everything displayed during the session) is stored in a named file using the date and time of each execution under the script log directory: _log\Executions\console_log-&lt;current_date_time&gt;.log using Start-Transcript of PowerShell<br>– Action logging (group member additions and deletions), appending to the same CSV file under script log folder: _log\action_log-&lt;group_name&gt;.csv (Six columns are available: date time directory_mode group action account)</li></ul><p>Refer to <a href="#e861">Flow</a> section for more details.</p><h3>Quick Start</h3><ol><li>Store the script with its complete <a href="#59b1">directory structure</a> in a location specified in the script (Default: C:\ws-dynamic-group)</li><li>Create ‘01_Incoming\entrant.csv’ according to the section <a href="#521b">CSV File Schema</a>.</li><li>In Windows Task Scheduler, create a task that runs ws-dynamic-group.ps1</li></ol><h3>Command Example</h3><pre>ws-dynamic-group.ps1 -csvPath &quot;C:\Folder\File.csv&quot; -groupName &quot;managers&quot; -force $true</pre><p>Refer to <a href="#5f98">Script Settings</a> section for details about the syntax and in-script settings.</p><h3>Prerequisites</h3><ul><li>A machine of Windows or Windows Server which can run PowerShell from the required modules, where:<br>– PowerShell module, Microsoft.Powershell.LocalAccounts, is required for &quot;local&quot; mode<br>– PowerShell module, ActiveDirectory, is required for &quot;domain&quot; mode (and only domain controllers are supported)</li><li>The group must be pre-created in the target system<br>– If the specified group is not created, the script cannot continue</li><li>Administrator rights<br>– The script must be executed with a user account in the AD group ‘Domain Admins’ for the ‘Domain’ mode or ‘Administrators’ group for the ‘Local’ mode, in order to add or delete group members successfully</li><li>Notes for ‘static’ input mode<br>– incoming.csv must be a complete file containing all the users (usernames) of the specified groups which must be processed.<br>– For example, if there are only a few group members in the CSV when the group in the live system actually has a lot of members, this will be regarded as an intentional deletion of all the group members from the group except those in the CSV file. (Mistakes may be prevented by configuring userDeletionThreshold threshold)</li><li>Refer to the notes under the section <a href="#521b">CSV File Schema</a></li></ul><h3>CSV File Schema</h3><p>Sample of CSV file (01_Incoming\incoming.csv) for domain mode:</p><pre>example_manager01<br>example_manager02<br>example_user01<br>example_user02</pre><p>Sample of CSV file (01_Incoming\incoming.csv) for local mode (where computer name has to be specified):</p><pre>HOSTNAME\example_manager01<br>HOSTNAME\example_manager02<br>HOSTNAME\example_user01<br>HOSTNAME\example_user02</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/0*yivJ4TN7BGABkT8_.png" /><figcaption>Example of local group members</figcaption></figure><p>Note:</p><ul><li>The group name can be either specified in the upper <a href="#5f98">variable section of the script</a> with the variable customGroupName or via command-line switch -groupName as in ws-dynamic-group.ps1 -groupName managers</li><li>Only one group name is supported per script. <a href="#e820">Multiple instances</a> can be achieved if required</li></ul><h3>Log File Schema</h3><pre>date,time,directory_mode,group,action,account<br>20190805,015512AM,Domain,students,Deletion,example_user01<br>20190806,035503PM,Local,managers,Addition,example_manager01</pre><p>Where the date and time of all records of each execution are equal to the time of execution of the script.</p><h3>Directory Structure</h3><p>The zip file can be extracted to the directory below, so that the following directory structure is created:</p><pre>C:\ws-dynamic-group<br>│<br>├───_log<br>│   │   action_log-&lt;group_name&gt;.log // Editable action log file of addition and deletion actions in CSV (one file per group)<br>│   │<br>│   └───Executions<br>│           console_log-&lt;date_time&gt;.log // console output logging of everything displayed (one file per run)<br>│<br>├───01_Incoming<br>│       incoming.csv // set manually (CSV &quot;static&quot; input mode) or generated in real time (dynamic &quot;LDAP&quot; input mode)<br>│<br>├───02_Processing<br>│<br>├───03_Done<br>│   │<br>│   └───&lt;date_time&gt; // e.g. 20190312_030304PM<br>│           Completed // indication of completion of script<br>│           Completed_Backup_(Before) // indication of the end of the script section: Backup (before)<br>│           Completed_Main_Logic // indication of the completion of the script section: Primary logic<br>│           Completed_Main_Logic-User_Addition // indication of completion of script section: Main Function - User Addition<br>│           Completed_Main_Logic-User_Deletion // indication of completion of script section: Main Function - User Deletion<br>│           Completed_Main_Logic-SKIPPED_User_Deletion // indication of skipping of script section: Main Function - User Deletion<br>│           Completed_Backup_(After) // indication of completion of script section: Backup (After)<br>│           incoming.csv<br>│           Domain|LocalGroupMemberAfter_full-time students.csv // optional: if enabled ($backupAfter is $true)<br>│           Domain|LocalGroupMemberAfter_managers.csv // optional: as above<br>│           Domain|LocalGroupMemberBefore_full-time students.csv // optional: if enabled ($backupBefore is $true)<br>│           Domain|LocalGroupMemberBefore_managers.csv // optional: as above<br>│<br>└───Scripts<br>        ws-dynamic-group.ps1</pre><h3>Flow of the Script</h3><p>This section describes the <a href="#59b1">directory structure</a> and the main actions performed by each execution of the script.</p><ol><li>Create a unique folder for each execution (to improve organization and avoid conflict)<br>– Randomize a unique value made up of day time in milliseconds</li><li>Backup Before — back up existing group members to a file<br>– [Local|Domain]GroupMemberBefore_(groupName).csv</li><li>Acquiring input<br>a. Acquiring usernames<br>– For ‘dynamic’ LDAP input mode, leverage specified LDAP query in the script to dynamically generate ‘incoming.csv’ in ‘01_Incoming’ folder<br>– For ‘static’ CSV input mode, acquire ‘incoming.csv’ from ‘01_Incoming’ folder (manually created by user) and move it to ‘02_Processing’ folder for processing<br>b. Acquiring group name<br>– A group name per script is specified at the top variable section of the script with the customGroupName variable</li><li>Main Function — perform action (adding/removing users from groups) specified in CSV<br>– Add users from CSV to local or AD group, if the users are in CSV but not in system<br>– Remove users from existing groups, if the users are not in CSV but in system</li><li>Move completed folders to ‘03_Done’ folder</li><li>Backup After — Back up final group members to a file<br>– [Local|Domain]GroupMemberAfter_(groupName).csv</li><li>Write a file named ‘Completed’ to ‘03_Done’ when each section of the script ends</li></ol><h3>Cases Handled by the Script</h3><p>Below are the cases handled by the script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*lEv-879Zj6cbHgQaBzz_tg.png" /></figure><h3>Script Section for Case 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*hSOZzhMU6u2GvwwnlZp_5w.png" /></figure><pre># Take action on users who only exist in the CSV<br>if ($directoryMode -ieq &quot;Local&quot;) {<br>    $beingAddedUsers = Compare-Object (Get-Content &quot;$scriptDir\02_Processing\$currentDateTime\LocalGroupMemberBefore_$csvGroupname.csv&quot;) (Get-Content &quot;$scriptDir\02_Processing\$currentDateTime\$csvFile&quot;) | Where-Object {$_.SideIndicator -eq &quot;=&gt;&quot;} | Select-Object -ExpandProperty inputObject<br>} elseif ($directoryMode -ieq &quot;Domain&quot;) {<br>    $beingAddedUsers = Compare-Object (Get-Content &quot;$scriptDir\02_Processing\$currentDateTime\DomainGroupMemberBefore_$csvGroupname.csv&quot;) (Get-Content &quot;$scriptDir\02_Processing\$currentDateTime\$csvFile&quot;) | Where-Object {$_.SideIndicator -eq &quot;=&gt;&quot;} | Select-Object -ExpandProperty inputObject<br>}</pre><pre>ForEach ($beingAddedUser in $beingAddedUsers) {<br>    # Add user, who are only found in CSV but not in system, to the group &#39;$customGroupName&#39; defined at the top variable of this script<br>    if ($directoryMode -ieq &quot;Local&quot;) {<br>        net localgroup `&quot;$customGroupName`&quot; `&quot;$beingAddedUser`&quot; /add<br>    } elseif ($directoryMode -ieq &quot;Domain&quot;) {<br>        net group `&quot;$customGroupName`&quot; `&quot;$beingAddedUser`&quot; /add<br>    }<br>}</pre><h3>Script Section for Case 3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*mwOue1tP5VgyulNWckyuUw.png" /></figure><pre># Take action on users who only exist in the system but not in CSV<br>if ($directoryMode -ieq &quot;Local&quot;) {<br>    $beingDeletedUsers = Compare-Object (Get-Content &quot;$scriptDir\02_Processing\$currentDateTime\LocalGroupMemberBefore_$csvGroupname.csv&quot;) (Get-Content &quot;$scriptDir\02_Processing\$currentDateTime\$csvFile&quot;) | Where-Object {$_.SideIndicator -eq &quot;&lt;=&quot;} | Select-Object -ExpandProperty inputObject<br>} elseif ($directoryMode -ieq &quot;Domain&quot;) {<br>    $beingDeletedUsers = Compare-Object (Get-Content &quot;$scriptDir\02_Processing\$currentDateTime\DomainGroupMemberBefore_$csvGroupname.csv&quot;) (Get-Content &quot;$scriptDir\02_Processing\$currentDateTime\$csvFile&quot;) | Where-Object {$_.SideIndicator -eq &quot;&lt;=&quot;} | Select-Object -ExpandProperty inputObject<br>}</pre><pre>ForEach ($beingDeletedUser in $beingDeletedUsers) {<br>    # Add user, who are only found in system but not in CSV, to the group &#39;$customGroupName&#39; defined at the top variable of this script<br>    if ($directoryMode -ieq &quot;Local&quot;) {<br>        net localgroup `&quot;$customGroupName`&quot; `&quot;$beingDeletedUser`&quot; /del<br>    } elseif ($directoryMode -ieq &quot;Domain&quot;) {<br>        net group `&quot;$customGroupName`&quot; `&quot;$beingDeletedUser`&quot; /del<br>    }<br>}</pre><h3>Tips</h3><ul><li>Parallel instances can be achieved by creating multiple copies of the script in different locations<br>– For example, the below sets of the script (scriptDir) can be created, each scheduled to run as required<br>– C:\ws-dynamic-group\1, C:\ws-dynamic-group\2, C:\ws-dynamic-group\3…</li><li>The script can be scheduled using built-in Task Scheduler of Windows or any other preferred auto-startup method</li><li>in PowerShell prompt, use &lt;tab&gt; key to auto-complete the command-line parameters without typing them in full</li><li>If Backup (Before) and Backup (After) are needed but the sysadmin finds it undesirable to execute them along with the Main Function (e.g. due to an increase of processing time), a separate script may be used and scheduled solely for the Backup sections to run separately</li></ul><h3>Current Limitations</h3><ul><li>Use of PowerShell equivalent for net group and net localgroup<br>– Currently, for ‘domain’ mode, the script must be run on a domain controller (due to the use of ‘net group’ commands) where the use of Remote Server Administration Tools (RSAT) would be unsupported</li><li>In local mode (workgroup), Get-LocalGroup and/or Get-LocalGroupMember returns usernames in NETBIOS format <em>HOSTNAME\Username</em> instead of <em>Username</em>; therefore, the schema of the input CSV file must be adjusted accordingly<br>– Two different input CSV files, one for domain and one for local, are included in this script as an example</li><li>Instead of a try-catch block, @ (Get-Content file | Select-Object) is used to work around a problem in which Compare-Object generates errors when the number of objects to compare is zero</li></ul><h3>Script Settings</h3><h3>Command-Line Parameters</h3><p>The essential parameters below can also be specified via the command line, replacing the equivalent ones in the script.</p><ul><li>-csvPath &lt;path to source file&gt;<br>e.g. -csvPath C:\Folder\File.csv in command line overrides $csvFile = &quot;incoming.csv&quot; in script</li><li>-groupName &lt;group name&gt;<br>e.g. -groupName &quot;managers&quot; in command line equals $customGroupName = $true in script</li><li>-force $true<br>e.g. -force $true in command line equals $forceUserDeletion = $true in script (Note: -force $false does not override the script equivalent)</li></ul><pre>Param(<br>    # Source file path<br>    # - Syntax:   -csvPath &lt;source file in absolute or relative path&gt;<br>    # - Example:  ws-dynamic-group.ps1 -csvPath &quot;C:\Folder\File.csv&quot;<br>    # - Note:     Overrides $csvFile specified inside script<br>    #             (No need to name the file as &quot;incoming.csv&quot;)<br>    [string]$csvPath,<br>    # Group name<br>    # - Syntax:   -groupName &lt;group name of AD domain or local workgroup&gt;<br>    # - Example:  ws-dynamic-group.ps1 -groupName &quot;managers&quot;<br>    # - Note:     Overrides $customGroupName specified inside script<br>    [string]$groupName,<br>    # Force user deletion (even if userDeletionThreshold is reached)<br>    # - Syntax:   -force $true<br>    # - Example:  ws-dynamic-group.ps1 -force $true<br>    # - Note:     Overrides $forceUserDeletion inside script<br>    #             (&#39;-force $false&#39; would not override the script equivalent)<br>    [boolean]$force<br>)</pre><h3>Internal Parameters</h3><p>More settings can be modified at Editable Settings section in ‘Scripts\ws-dynamic-group.ps1’:</p><pre># [Editable Settings]</pre><pre># ------- General Settings -------</pre><pre># Script directory<br># - Determine the working directory of the script and the relative path<br># - Tip: If multiple instances are required, create copies of the script folder structure and set each scriptDir to be:<br>#   - Example 1: &quot;c:\ws-dynamic-group\1&quot; (where this script can be located at c:\ws-dynamic-group\Scripts\1\ws-dynamic-group.ps1)<br>#   - Example 2: &quot;c:\ws-dynamic-group\2&quot; (and so on)<br>$scriptDir = &quot;c:\ws-dynamic-group&quot;</pre><pre># Format of date and time <br># - Used for uniquely naming and creating a new directory on each run by randomizing a value made up of day time<br># - Example: Get-Date -format &quot;yyyyMMdd_hhmmsstt&quot; (e.g. &quot;20190227_095047AM&quot;)<br>$currentDateTime = Get-Date -format &quot;yyyyMMdd_hhmmsstt&quot;</pre><pre># ------- Section(s) of Script to Run -------<br># <br>$mainFunction = $true # Perform the main function of the script<br>    $userAddition = $true # Perform user addition for each user that is in CSV but not in system<br>    $userDeletion = $true # Perform user deletion for each user that is in system but not in CSV<br>$backupAfter = $true # Record final group members to a log file (Output File: GroupMemberAfter_GroupName.csv)</pre><pre># ------- Settings - Input Source -------</pre><pre># Input mode<br># - Either case-insensitive &#39;static&#39; (CSV) or &#39;dynamic&#39; (LDAP)<br>#   - Static: Acquire CSV file pre-created and pre-inputted by user in 01_Incoming directory<br>#   - Dynamic: Also ends up being a CSV file, but generated live via a LDAP filter from current Active Directory domain<br># - Note: dynamic LDAP input mode automatically assumes &#39;Domain&#39; and overrides &#39;Local&#39; directory Mode<br># - Example 1: $inputMode = &quot;Dynamic&quot;<br># - Example 2: $inputMode = &quot;Static&quot;<br>$inputMode = &quot;Static&quot;</pre><pre>    # Directory mode (for both input modes)<br>    # - Determine whether to interact with local (workgroup) or domain (AD) authentication provider<br>    # - Either case-insensitive &#39;Local&#39; or &#39;Domain&#39;<br>    #   - &#39;Local&#39; (workgroup) directory mode where local group would be enumerated,<br>    #   - &#39;Domain&#39; directory mode which is only supported to be run on a domain controller<br>    # - Note: If input mode is set to dynamic (LDAP), this has NO EFFECT and is automatically assumed to be &quot;Domain&quot;<br>    # - Example 1: $directoryMode = &quot;Local&quot;<br>    # - Example 2: $directoryMode = &quot;Domain&quot;<br>    $directoryMode = &quot;Domain&quot;</pre><pre>    # ------- Settings - Dynamic Input Mode -------</pre><pre>    # LDAP filter<br>    # - Acquire a list of users from AD domain to generate a CSV file for further processing (used by dynamic LDAP input mode)<br>    # - Example 1 (AND):  (&amp;(otherFacsimileTelephoneNumber=1)(otherPager=1))<br>    # - Example 2 (OR):   (|(otherFacsimileTelephoneNumber=1)(otherPager=1))<br>    # - Example 3 (STAR): (samAccountName=s9999*)<br>    # - Example 4 (MORE): ((mailNickname=id*)(whenChanged&gt;=20180101000000.0Z))(|(userAccountControl=514))(|(memberof=CN=VIP,OU=Org,DC=test,DC=com)))<br>    $ldapFilter = &quot;(|(otherFacsimileTelephoneNumber=1)(otherPager=1))&quot;</pre><pre>    # ------- Settings - Static Input Mode -------</pre><pre>    # NOTE: The below has NO EFFECT when source file path is specified via command line: e.g. ws-dynamic-group.ps1 -csvPath &quot;C:\Folder\file.csv&quot;</pre><pre>    # CSV filename<br>    # - For processing inside 01_Incoming folder (used by static CSV input mode)<br>    # - Example: $csvFile = &quot;incoming.csv&quot;<br>    $csvFile = &quot;incoming.csv&quot;</pre><pre># ------- Settings - Group Name -------</pre><pre># NOTE: The below has NO EFFECT when group name parameter is specified via command line: e.g. ws-dynamic-group.ps1 -groupName &quot;managers&quot;</pre><pre># Custom group name<br># - One group name can be specified here in each script<br># Example: $customGroupName = &quot;managers&quot;<br>$customGroupName = &quot;managers&quot;</pre><pre># ------- Settings - User Deletion Threshold -------</pre><pre># Skip user deletion when the below threshold is reached<br># Set it to a desired value e.g. 0.8 (80%)<br># Example: $userDeletionThreshold = 0.8<br>$userDeletionThreshold = 0.8</pre><pre># NOTE: The below has NO EFFECT when force parameter is specified via command line: e.g. ws-dynamic-group.ps1 -force $true</pre><pre># Force user deletion even when threshold is reached<br># Example: $forceUserDeletion = $true<br>$forceUserDeletion = $false</pre><pre># ------- Settings - Email -------</pre><pre># Send mail alerts to report skipping of user deletion due to reaching threshold<br>$mailSender = &quot;Sender &lt;sender@wandersick.com&gt;&quot;<br>$mailRecipient = &quot;Recipient A &lt;recipienta@wandersick.com&gt;&quot;, &quot;Recipient B &lt;recipientb@wandersick.com&gt;&quot;<br>$mailSubjectFailure = &quot;WS-Dynamic-Group Member Deletion Skipped - &quot; + $currentDateTime<br>$mailBodyFailure = &quot;This is an automated message after WS-Dynamic-Group script skips user deletion due to the number of users being deleted reaches defined threshold:`n`n - userDeletionThreshold of $userDeletionThreshold`n`nFor details, please check the folder where the WS-Dynamic-Group script is executed, which is named using the same timestamp in this email subject at:`n`n - $scriptDir\03_Done\$currentDateTime`n&quot;<br>$mailServer = &quot;10.123.123.123&quot;</pre><h3>Download</h3><p>The latest release of ws-dynamic-group can be downloaded from its <a href="https://tech.wandersick.com/2020/06/automate-windows-group-member-update-via-csv-or-ldap-with-powershell.html#download">homepage</a>.</p><h3>Release History</h3><p>Version 3.0–20200613</p><ul><li>Non-functional improvements</li></ul><p>Version 2.3–20190808</p><ul><li>Fix the display bug of the currentAction variable in the CSV log file</li><li>Fix the deletion action not being logged</li></ul><p>Version 2.2–20190806</p><ul><li>Add console output log file under script log directory: _log\Executions\console_log-&lt;current_date_time&gt;.log achieved using Start-Transcript PowerShell cmdlet</li><li>Add a (modifiable) action log file in CSV format under script log directory: _log\action_log-&lt;group_name&gt;.csv with actions &quot;Addition&quot; and &quot;Deletion&quot; recorded<br>– 6 columns are in the action log file (CSV): date time directory_mode group action account</li><li>Set $PSScriptRoot as the script root (where the script can be placed and executed anywhere)</li></ul><p>Version 2.1–20190604</p><ul><li>Perform pre-checking prior to deleting user to avoid error of deleting a large number of users<br>– A userDeletionThreshold will be checked before user deletion<br>– When threshold userDeletionThreshold is reached (e.g. 0.8 meaning if over 80% of users will be deleted, skip the operation)</li><li>Once the user deletion operation has been skipped, an email indicating which execution has failed will be sent to alert the system administrator</li><li>Force (forceUserDeletion) parameter is supported when system administrator decides to continue even if userDeletionThreshold is reached</li><li>Accept several essential named parameters via the command line, replacing the equivalent ones in the script<br>-csvPath &lt;path to source file&gt;<br>-groupName &lt;group name&gt;<br>-force $true</li></ul><p>Version 2.0–20190528</p><ul><li>Minimize the iterations of for-loops (ForEach-Object) for performance enhancement by:<br>– Replacing the comparisons in Main Function with Compare-Object<br>– Eliminate the use of ‘ForEach-Object’ for replacing characters with ‘Select-Object -ExpandProperty’</li><li>It is no longer necessary to specify <em>Username</em> as the header in a CSV file</li><li>The backupBefore parameter is no longer available for customization because backing up group members beforehand is now a hard requirement being a comparison source for Compare-Object cmdlet<br>– The output file of backupBefore has been reformatted to a single column in order to fit the comparison. (The backupAfter output file has also been reformatted to align with the change, although this is not technically required, it still makes comparison easier in case of troubleshooting.)</li></ul><p>Version 1.3–20190414</p><ul><li>Maintenance release — no new feature. (Therefore, keep using the last version would be OK)</li><li>Update README document and refactor code for the purpose of an easier reading<br>– Remove deprecated feature — only one group name can be specified, at the top variable section of the script (specifying multiple group names in CSV was deprecated in the last version)</li></ul><p>Version 1.2–20190409</p><ul><li>Performance enhancement<br>– Rough calculation of an execution of 10,000 objects is 3 times faster than last time</li><li>Reduces the number of for-loops and/or nested for-loops</li><li>Script has been separated into three sections which can be optionally enabled: Backup (Before), Main Function and Backup (After)<br>– For performance reasons, only Main Function is enabled by default</li><li>Within Main Function, more granularity is achieved by further separating it into User Addition and User Deletion. Each of them can be enabled and run sequentially or in parallel as required<br>– For example, two sets of the script with similar settings, with the only difference being set A having userAddition enabled and set B having userDeletion disabled, may be run in parallel to speed up user addition and deletion</li><li>Group name has to be specified at the top of script<br>– Specifying it in CSV is no longer supported<br>– Only one group name can be specified</li></ul><p>Version 1.1–20190315</p><ul><li>In addition to the already supported group member updating method of statically creating CSV input file, dynamic LDAP input mode is now supported, where incoming.csv is generated according to an LDAP query specified in the script, live from current Active Directory domain</li></ul><p>Version 1.0–20190312</p><ul><li>Monitor a CSV file for additions or deletions of users in one or more groups (as a scheduled task)</li><li>Apply the modifications to the system accordingly, locally or on a domain controller (Active Directory)</li><li>Support for local (workgroup) and domain (Active Directory) environments</li></ul><p>Hope this article or the tool is useful to you. 😊</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2020/06/automate-windows-group-member-update-via-csv-or-ldap-with-powershell.html"><em>https://tech.wandersick.com</em></a><em> </em>on May 12, 2019.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6db1b2de52d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/automate-windows-group-member-update-via-csv-file-or-ldap-query-with-powershell-6db1b2de52d5">Automate Windows Group Member Update via CSV File or LDAP Query with PowerShell</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Skills to Get Equipped Career-wise amid COVID-19]]></title>
            <link>https://medium.com/wandersick/skills-to-get-equipped-career-wise-amid-covid-19-6228782b0943?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/6228782b0943</guid>
            <category><![CDATA[remote-work]]></category>
            <category><![CDATA[work-from-home]]></category>
            <category><![CDATA[telecommuting]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[freelancing]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 16:55:35 GMT</pubDate>
            <atom:updated>2026-10-11T13:26:06.579Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Recently, I received an email invitation about writing an article on working from home (WFH) amid coronavirus outbreak. As an IT professional who still does much work in a traditional face-to-face way, that led to my interest in the topic, resulting in a presentation I have done privately and finally this post — this article discusses a way the pandemic has changed our lives and how I personally cope with it career-wise by getting equipped with desired skills on remote-work marketplaces.</p><h3>Problem — Coping with Remote Work, the New Normal</h3><p>A wise person once said the only constant is change — have you noticed what has changed during the pandemic?</p><p>Lately, people in certain parts of the world are joking weather and safety leave* will no longer be a thing due to the boom of communication technologies such as Slack, Zoom and Microsoft Teams, which turned remote work (telecommuting) into the new normal — you and I may still need to work like usual as long as the Internet is not broken.</p><p><em>*While natural disaster can be devastating and affect safety of people, there are also people who are less affected and they may still be entitled to weather and safety leave where they can take a rest.</em></p><figure><img alt="Remote-work communication tools" src="https://cdn-images-1.medium.com/max/640/0*trFsRH57Zx-QAs7d.png" /><figcaption>Remote work communication tools</figcaption></figure><p>Coincidentally, before the pandemic, Satya Nadella, the current CEO of Microsoft, had a <a href="https://www.cnbc.com/2019/12/24/what-microsoft-ceo-satya-nadella-does-instead-of-work-life-balance.html">news article</a> of him discussing about an alternative view on work-life balance — work and life should be harmonized, coining the phrase “work-life harmony”, where work and life are more like a mesh instead of balance. Interestingly, this will likely turn out to be true too in the post-pandemic era, as the pandemic has opened people’s eyes to what is possible with remote work even after the pandemic passes.</p><p>However, people may not be familiar with remote work — not many industries or companies adopted the remote-work model before the pandemic. As remote work gets more and more popular, in the post-coronavirus era, people will be able to obtain remote jobs more easily than before, only if they are equipped with remote-work skills. So how should one cope with that? Here is a way I recently experienced due to my desire to explore and improve my remote-working skills.</p><h3>Solution — Remote Work Marketplaces</h3><p>Have you heard of remote work marketplaces like Fiverr, Upwork, Freelancer.com, etc.? These are online freelancing platforms which provide the service of matching freelancers with businesses. They became popular amid COVID-19 due to the lockdown and some companies laying off employees for cost-cutting outsourcing options. Many of these platforms saw <a href="https://www.cnbc.com/video/2020/05/11/upwork-ceo-pandemic-highlights-remote-work-benefits-for-workers-environment.html">a surge in traffic</a> during the pandemic, as reflected in their stock price.</p><figure><img alt="Remote-work marketplaces" src="https://cdn-images-1.medium.com/max/640/0*qvniuTmcw6xxDKKd.png" /><figcaption>Remote work marketplaces</figcaption></figure><p>(Personally, I tried all three platforms and had more success on Upwork than the other ones, so Upwork is the one I mainly talk about in this article. Your mileage may vary and other platforms may be more suitable to you or your industry.)</p><p>Take <a href="https://www.upwork.com/">Upwork</a> as an example. Founded in 1999, Upwork is one of the top marketplaces for remote work. It matches businesses and talents from 180 countries. Clients include Microsoft and over 30% of Fortune 500 companies. Freelancers using these platforms for freelancing usually get to enjoy payment protection via their escrow service. In turn, companies using them to hire freelancers can also more easily look for the right candidate by filtering or preferring freelancers that meet their specific criteria. In the case of Upwork, it could be meeting location and language requirements, or different verification options specific to Upwork, e.g. <a href="https://support.upwork.com/hc/en-us/articles/211063568-Top-Rated-and-Rising-Talent">Top-Rated and Rising Talent</a> to identify quality freelancers. As a middle entity, platforms like Upwork can escrow services, simple contract management, faster payments, settle dispute or provide assistance in case either side is in trouble, letting both sides focus on what matters to them — the business itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q_fCwY8W0xpK6JwkC8uF_Q.png" /><figcaption><em>Upwork has awarded me with Rising Talent status thanks to having a good start and </em>meeting several <a href="https://support.upwork.com/hc/en-us/articles/211063228">other criteria</a><em>. (Tips on how to achieve a great start will be provided in the Tips section futher down below.)</em></figcaption></figure><h3>Benefits — How Remote Work Marketplaces Improve One’s Skills</h3><h4>1. Opportunities to experience unfamiliar territories</h4><p>(As a person who loves to explore, the first two points are the most important factors for me!)</p><p>While earning to make a living is important, being a technology enthusiast myself, having a platform where I can learn or practice desired skills in a real work environment with tech companies is also a huge motivator for me personally — there aren’t really that many opportunities in real life as compared to remote work marketplaces with a large number of clients. In the case of Upwork, some of their high-profile clients are Airbnb and Microsoft.</p><h4>2. Engage in tasks that prepare one for a target career</h4><p>Extending the above point, with the large variety of opportunities available on remote work marketplaces, people can sharpen their desired skills with an aim of getting equipped with skills related to their dream jobs by first acquiring virtual work experience related to their jobs, even before they are hired in real life.</p><p>Once in a while, there are also clients that are job interview exam providers. They may offer special tasks which involve creating, reviewing or test-driving job interview questions (e.g. PowerShell coding test in the case of a Microsoft DevOps job interview). In case that meets one’s dream job criteria, he/she would be able to experience a similar job interview process even before being admitted to the actual job interview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*jzb9CeieTZoPFna4lOzLFg.png" /><figcaption>Client looking for freelancers to test drive screening exercises used in hiring processes, e.g. coding</figcaption></figure><h4>3. Get good with proposal writing, contract bidding</h4><p>Through a platform like Upwork (Fiverr works differently though), freelancers get to sharpen their proposal-writing and contract-bidding skills through negotiation with a large varieties of clients. (These are soft skills that are invaluable in real life too!) Once we master the art of them, we can more easily attract clients, win contracts and shine on the platforms.</p><h4>4. Familiarize with a pure remote work environment</h4><p>Finally, this point brings the focus back to the main theme of this post — due to COVID-19, remote work has become a norm during and even after the pandemic, with which employees from traditional industries may not yet be familiar. In order to survive and thrive, one has to get familiar with the tools involved in a usual remote work setup, such as Zoom, Slack, Microsoft Teams, as well as the soft skills involved. On remote work marketplaces, one gets to experience a pure remote work environment to get prepared for the WFH future.</p><h3>Tips — Shine on Remote Work Marketplaces</h3><h4>1. First few contracts are key</h4><p>In order to have a good career on the platforms, it is important to pick clients who give 5-star ratings and pick jobs with which we are confident to overdeliver. Great ratings and comments from the first few jobs make future ones easier. For example, there are clients on Upwork who would prefer freelancers with at least 90% of success rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*r51jqyBA6D7WMqCQyyVJdg.png" /><figcaption>Having a good work history of successful jobs, five stars and good comments unlock future opportunities for new freelancers</figcaption></figure><h4>2. Craft client-attracting profile and contract-winning proposals</h4><p>Take time to research on how to write a client-attracting profile and contract-winning proposals for your specific industry, in order to truly shine on the platforms. I found the YouTube videos from <a href="https://www.youtube.com/watch?v=rcKFdF7pNtg&amp;list=PL2RRbYdV_lUSJ_9B0EqnITq_KaS1PlGSE">Josh Burn Tech</a> to be a big help to get me started. (Thanks!) I believe writing a good profile also helped me pass the newcomer screening of Upwork and reduced the number of Upwork credits I wasted during proposal submission.</p><h3></h3><p>You&#39;re so welcome. Great work! 👍</p><h4>3. Empower your screen-sharing demo on Zoom with AeroZoom</h4><p>There are many times where I would have to remote-control a computer or perform a live demo on Zoom (or Cisco WebEx, Microsoft Teams, etc.) during remote work. I found my free Windows wheel-zooming application, <a href="https://medium.com/wandersick/aerozoom-a-smooth-wheel-zooming-mouse-enhancing-panel-cd2bdc5e6489">AeroZoom</a> magnifier 🔎 (which you may have seen on Lifehacker and other media), helpful in enlarging small texts and elements on my computer screen conveniently with just <a href="https://farm8.staticflickr.com/7849/46340700265_33a567d956_o.gif">a single mouse</a> using Left mouse button + Wheel-up/down (or a Mac-like hotkey e.g. Alt key + Wheel-up/down), so that viewers and I can view more clearly and focus on specific area of screen zoomed in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*6qUK_6GiGUid38f2BLptiA.png" /><figcaption>Zoom in and out one-handedly with <a href="https://medium.com/wandersick/aerozoom-a-smooth-wheel-zooming-mouse-enhancing-panel-cd2bdc5e6489">AeroZoom</a> screen magnifier</figcaption></figure><h3>Conclusion — 3 Takeaways</h3><ol><li>Although country borders are closing and traditional opportunities are shrinking, we can still leverage opportunities on remote work marketplaces.</li><li>Owing to the shift from face-to-face work to remote work, we have to invest in skills and learn about tools that enable or supplement the new way of work. We can practice the use of them on remote work marketplaces.</li><li>If we lack opportunities to get good with desired skills required by our next stage of career in real life, we can get good at them first on remote work marketplaces, due to the large variety of jobs available on those platforms.</li></ol><p>I hope you find this article helpful regarding my recent experience. I would be delighted if it gives you some new ideas on how to cope with the current lockdown or even the remote-work future. Finally, I hope we can be better together. ❤️️</p><p>Stay safe!</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2020/06/skills-to-get-equipped-career-wise-amid.html"><em>https://tech.wandersick.com</em></a><em> on June 2, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6228782b0943" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/skills-to-get-equipped-career-wise-amid-covid-19-6228782b0943">Skills to Get Equipped Career-wise amid COVID-19</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10+ Smart-Working Enterprise IT Work Rules]]></title>
            <link>https://medium.com/wandersick/10-smart-working-enterprise-it-work-rules-e155532d86fe?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/e155532d86fe</guid>
            <category><![CDATA[work-ethic]]></category>
            <category><![CDATA[professionalism]]></category>
            <category><![CDATA[smart-working]]></category>
            <category><![CDATA[it-support]]></category>
            <category><![CDATA[email]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Sat, 02 May 2020 12:54:41 GMT</pubDate>
            <atom:updated>2022-06-19T11:32:48.831Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Do you wonder what the work principles in IT (information technology) are like in an enterprise? As a young IT professional in a large enterprise, there were rules I had to learn in order not to go out of line — it was 2011, the first time I ever stepped into the world of IT support, where I learned the essentials from my supervisor and mentor who always told me not to work hard but work smart. This is a list of IT work ethic reminders I crafted for myself thanks to him, hoping it would be inspiring to everyone, working in the tech industry or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S92P0w35G3zAwfke" /><figcaption>Photo by <a href="https://unsplash.com/@jessedo81?utm_source=medium&amp;utm_medium=referral">jesse orrico</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><ol><li>Most of the time, IT support is a standby job — it may be peaceful but we should <strong>get prepared for the worst</strong> to come anytime.</li><li><strong>Underpromise and overdeliver</strong>. We should leave buffer time when asked to provide with an estimated time required to fulfill a request. (If done early, users or requesters would be more satisfied.)</li><li>We would not be much different from workers in the industrial age if we don’t think and just do as we are told. When assigned a task, we should be curious. We should ask. We should <strong>seek every bit of detail</strong>. We should then plan<strong> </strong>and <strong>state clearly any risks to avoid taking responsibility</strong> in case of failure.</li><li>When answering the management, <strong>do not rush</strong> to say yes or boldly suggest when we aren’t sure. Just chill and say we don’t know or we need to look into it first.</li><li>To maintain IT operations of an enterprise, sometimes <strong>doing nothing</strong> is better for users and the company in long term. For example, working around a slow 10-year-old PC to mitigate compatibility issues is bad. Why not use it as a reason to support buying a new PC that makes the user more productive and happy?</li><li><strong>Get to know one or two colleagues well in each department</strong>. That will help make our work smooth, e.g. conducting a pilot test would encounter less reluctance from users we know better.</li><li><strong>Avoid writing long emails</strong> which are often ignored or skim-read by users. Make emails concise and in point form so that users easily grasp them and do what we would like them to do.</li><li><strong>Email is official</strong> <strong>(and cold)</strong>. Never take sending emails as the sole action. Carbon-copying (cc) to lots of people or users’ department head could be invasive. Always casually talk to the user first, then email.</li><li><strong>Don’t be too nice to users</strong>. In a big enterprise, our role is like the police, while users are like citizen. Rules are rules. We do not teach users how to violate rules; they could, however, figure out certain harmless shortcuts by themselves, as no policeman or policewoman would instruct pedestrians they can cross a car-free road when the pedestrian traffic light is red.</li><li>We should not let users feel we are soft in <strong>saying no</strong>. We should be firm in enforcing policies.</li><li>If we really would like users to obey IT rules and respect one another, whether it is email or talk, <strong>be firm, concise and to the point</strong>.</li><li>Being <strong>strict first, loose later</strong> would be better regarded by users than being loose first and strict later.</li><li><strong>Think in the mind of challengers</strong> (e.g. auditor, the management). Anything that is emailed, logged, signed can be later challenged. Do not give in to laziness or convenience and let users bypass process, such as not requiring approval for installing high-risk software. We don’t want to cause trouble to our managers later.</li><li>Because of our role of helping people, users and even the management can be very nice to us, but we should maintain our professionalism, which is what they expect from us. <strong>Stay humble, sincere, diligent and be courteous</strong> to everyone at all times.</li><li>IT professionalism also includes <strong>not peeking at users’ emails and files</strong>. Do not abuse our privileges (in front of users or behind them) without their consent.</li></ol><p>I hope these rules will be of use to anyone new to the world of enterprise IT support and similar disciplines.</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2016/06/10-smart-working-enterprise-it-rules.html"><em>https://tech.wandersick.com</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e155532d86fe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/10-smart-working-enterprise-it-work-rules-e155532d86fe">10+ Smart-Working Enterprise IT Work Rules</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Windows Hardening with Infrastructure-as-Code — Chef and Inspec]]></title>
            <link>https://medium.com/wandersick/quick-windows-hardening-with-chef-infrastructure-as-code-aa8095a64cfe?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/aa8095a64cfe</guid>
            <category><![CDATA[security-compliance]]></category>
            <category><![CDATA[hardening]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[windows-security]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Sun, 24 Nov 2019 03:02:05 GMT</pubDate>
            <atom:updated>2020-07-25T08:09:05.248Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Quick Windows Hardening with Infrastructure-as-Code — Chef and Inspec</h3><p>CIS, Center for Internet Security, publishes prescriptive system hardening documents which provide guidance for establishing a secure system configuration on platforms such as Windows. Usually, their Windows hardening documents are over a hundred pages long and would take a long time to perform hardening manually by one person. Thankfully, there is an Infrastructure-as-Code configuration management approach, e.g. the one introduced below leveraging <em>Chef</em> and <em>Inspec</em>, to achieve automation of the hardening process and validating the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUBOmaWH6x9e3hFIeVuw0A.png" /><figcaption><strong>Figure 1.</strong> Content of harden_winrm.rb, with references from CIS sections as an example of Chef recipes. (This one is from <a href="https://github.com/MattTunny/windows_hardening">MattTunny/windows_hardening</a> GitHub repository)</figcaption></figure><p>Instead of demonstrating the <a href="https://docs.chef.io/chef_overview.html">power of infrastructure as code</a> fully, this quick post only aims at introducing the concept by leveraging Chef hardening recipes found on the Internet, showing the steps to perform Windows hardening on a single local machine quickly, which may suit one-time use cases. We will install Chef Development Kit to use chef-apply for applying Chef recipes to harden a local machine and inspec for verifying the hardening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/0*WI5J52LuOi-8eXhY" /><figcaption><strong>Figure 2.</strong> Installing Chef Development Kit</figcaption></figure><h3>Tools Required</h3><ol><li>Chef cookbook or recipes for Windows OS hardening (e.g. ones from my GitHub repository below, <a href="https://github.com/wandersick/windows_hardening">wandersick/windows_hardening</a>, originally forked from <a href="https://github.com/MattTunny/windows_hardening">MattTunny/windows_hardening</a> GitHub repository, adjusted to fit the examples using the chef-apply approach in this article. You may use others found on the Internet, or craft ones that are catered to your needs)</li></ol><p><a href="https://github.com/wandersick/windows_hardening">wandersick/windows_hardening</a></p><p>Download: <a href="https://github.com/wandersick/windows_hardening">https://github.com/wandersick/windows_hardening</a></p><ul><li>Chef recipes crafted according to <a href="https://www.cisecurity.org/cis-benchmarks/">CIS-published guidance</a></li><li>The example is for Windows Server 2012 and 2012 R2, which is similar for Windows Server 2016 and 2019</li><li>You should customize. Here are some ideas:<br><strong>a.</strong> You may not want to run some of the recipes which break functionalities such as harden_winrm.rb (WinRM)<br><strong>b.</strong> In core_hardening.rb, you may want UAC to be disabled (EnableLUA not set to 1), the warning text displayed at logon to be different (legalnoticecaption and legalnoticetext edited as desired). For domain controllers, you may want EnableAuthEpResolution to be removed in order to enable certain cross-forest/domain scenarios. For older printers/scanners/copiers not supporting NTLMv2 for scanning to shared folders, or you are encountering an issue in which Remote Desktop client keeps saying ‘the logon attempt failed’, you may want LmCompatibilityLevel to be removed. Similarly for RestrictNTLMInDomain if it is a domain controller.<br><strong>c.</strong> In localComputer.inf, you may prefer NewAdministratorName and NewGuestName are not set to _administrator and _guest, the maximum password age (MaximumPasswordAge) not set to 42 days, and the minimum password length (MinimumPasswordLength) not set to 14<br>(All of the above are the default settings from the recipes)</li><li>Some recipes require specific variables to be defined such as cwd for the path to some configuration files. Be sure to refer to the README.md and comments within each recipe file.</li></ul><p>2. RegShot 2.0.1.70 (optional)</p><p><a href="https://www.wincert.net/forum/index.php?/files/file/16-regshot2-unicode/">RegShot2 Unicode</a></p><p>Download: <a href="https://www.wincert.net/forum/index.php?/files/file/16-regshot2-unicode/">https://www.wincert.net/forum/index.php?/files/file/16-regshot2-unicode</a> <br>(This site requires account registration and login prior to download)</p><ul><li>This utility compares registry changes before and after hardening, provides a report of which, allows backup of registry in <em>.reg</em> and <em>.hiv</em>e files, as well as producing <em>UNDO</em> and <em>REDO</em> reg files</li></ul><p>3. Chef Development Kit installed on a supported Windows machine</p><p><a href="https://downloads.chef.io/chefdk#windows">Chef Downloads</a></p><p>Download: <a href="https://downloads.chef.io/chefdk#windows">https://downloads.chef.io/chefdk#windows</a></p><ul><li>Although the Chef Development Kit provides a lot of features, we will only use chef-apply for applying recipes (.rb files) to a local machine and inspec<em> </em>for verification</li><li>The version used for this article is 4.4.27–1</li></ul><p>4. Windows Command Prompt (run as administrator)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/0*4JuBXNSTgnsGl6ZV" /><figcaption><strong>Figure 3.</strong> Ensure Command Prompt is run as administrator; otherwise, <em>chef-apply</em> would not run correctly later</figcaption></figure><h3>Pre-Hardening Configuration</h3><ul><li>Install Chef Development Kit (on the target system to be hardened) with default settings</li><li>Add C:\opscode\chefdk\bin\ to the environment variable — %PATH% — if not already added</li><li>Store downloaded windows_hardening directory like our working directory in this example, c:\temp\windows_hardening instead of c:\temp\windows_hardening-master which may be inaccurately shown in a few screenshots</li></ul><h3>Pre-Hardening Verification and Backup</h3><ul><li>For safety, back up the OS drive or at least the system state (most of the settings are registry settings)</li><li>Perform <em>1st shot</em> with Regshot 2.0<br>- Save <em>.reg</em> and <em>.hive</em> files (for an additional backup)<br>- Do not close the Regshot application yet (a <em>2nd shot</em> will be run at the end of hardening as a comparison)</li><li>Verify with inspec<br>- See a report of what have been hardened and what have not, for comparison later:</li></ul><pre>cd C:\temp\windows_hardening\<br>inspec exec test/integration/default/default_spec.rb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/0*7bQ1GbNzvys8vH_H" /><figcaption><strong>Figure 4.</strong> Performing <em>inspec</em> checking before hardening reports a lower number of successful items</figcaption></figure><h3>Performing Hardening</h3><p><strong>Friendly reminder</strong>: Ensure this is not done to a system without thoughtfulness — it is normal for issues to emerge after hardening. Think twice. Still insist? OK. Here you go!</p><p>First, ensure we are at the directory containing recipes.</p><pre>cd C:\temp\windows_hardening\recipes<br>dir</pre><p>Run the listed OS hardening recipes as needed with one of the chef-apply methods below.</p><ul><li>Either apply recipes one by one using chef-apply, e.g. on the main recipe file containing most of the settings by replacing &lt;file_name&gt;.rb with core_hardening.rb:</li></ul><pre>chef-apply &lt;file_name&gt;.rb</pre><ul><li>Or apply multiple recipes in a go using chef-apply with a for loop:</li></ul><pre>for /f &quot;usebackq tokens=* delims=&quot; %i in (`dir /b`) do chef-apply &quot;%i&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VgoBNdXiGNdZ8PlI" /><figcaption><strong>Figure 5.</strong> Applying OS hardening Chef recipe with <em>chef-apply</em>. (Note: some errors may be inevitable)</figcaption></figure><p><strong>Tips</strong></p><ol><li>For the for-loop technique, please be reminded to carefully examine what will execute as all contents from all recipes will be applied. Some recipes may have a special purpose which are not meant to be run this way.</li><li>Most hardening rules should work out of the box and do not require further modification if you choose the compatible Chef recipe named core_hardening.rb (where most of the hardening rules reside).</li></ol><p><strong>Side Talk — Ideas for Fixing Recipes Incompatible with </strong><strong>chef-apply</strong></p><p>Let’s take a detour before verifying the results.</p><p>The use of chef-apply in this post (treating Chef recipes as scripts), while straight-forward for a quick demonstration or use, <a href="https://www.oreilly.com/library/view/chef-powerful-infrastructure/9781788392976/ch16s07.html">is not how Chef is run in production</a>. If you use recipes not from my GitHub repository, you might encounter errors for those incompatible withchef-apply. As an example, in <a href="https://github.com/MattTunny/windows_hardening">this repository</a>, a majority of errors encountered in the incompatible recipes were eliminated by manually modifying .rb files.</p><p>For example, for the harden_winrm.rb recipe in Figure 1 (the top of this article), remove the first line after comment, and if … end outer wrapping from each block, leaving only inner registry_key … end parts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*psZTu4BNSlMd-Q0cfU1ORQ.png" /><figcaption><strong>Figure 6.</strong> An edited version of harden_winrm.rb (lower) in comparison with before hardening, i.e. Figure 1 (upper), where the outer if … end has been stripped off</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*o-1OhZjjie4p5dVno84wRQ.png" /><figcaption><strong>Figure 7</strong>. After the edit, chef-apply harden_winrm.rb command runs correctly</figcaption></figure><h3>Post-Hardening Verification and Backup</h3><p>Verify with inspec again after applying (Observe the increase in the count of passed items and the decrease in failed items.</p><pre>cd ..<br>inspec exec test/integration/default/default_spec.rb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/0*cqZTuiReCbLWdK8Y" /><figcaption><strong>Figure 8.</strong> Running the inspec command — 1st run vs 2nd run (on an unsupported Windows 10 1709 testing machine for showing the difference only) where the second run has a lower number of failed items</figcaption></figure><p>(The test run results in Figure 9 are available are <a href="https://github.com/wandersick/windows_hardening/blob/master/TESTRUN.md">available for viewing here</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*J2WapF3XZ8Uci6uCqSxGiA.png" /><figcaption><strong>Figure 9</strong>. 213 successful and 0 failed items are reported in a case of mine on Windows Server 2016, where my chef-apply-adapted <a href="https://github.com/wandersick/windows_hardening">fork of the hardening recipes</a> were used</figcaption></figure><p>Perform <em>2nd </em>shot with Regshot 2.0 (to compare registry changes)</p><ul><li>Save .<em>reg</em> and .<em>hive </em>files (for backup)</li><li>Back up C:\HIVE folder (the Regshot working folder) which contains UNDO and REDO <em>reg</em> files, which are useful for rollback and for understanding what has changed. (Note that some keys are unrelated due to other concurrent Windows activities)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/0*gdVyQif9lNb0FBdR" /><figcaption><strong>Figure 10.</strong> Regshot 2.0 produces RedoReg.txt and UndoReg.txt</figcaption></figure><p>For failed items reported by the second inspec run which should be much lower now (e.g. 25 failed items in a case of mine on Windows Server 2016, where some of the recipes were left out intentionally; 0 failed items in another case). In case of any issues, you can also always fix them according to the official <a href="https://www.cisecurity.org/cis-benchmarks/">CIS Benchmarks</a> documents. For user rights and privileges, it would be useful to refer to <a href="https://technet.microsoft.com/en-us/library/dd277311.aspx">Microsoft documentation</a> as well.</p><h3>Is It Good to Go?</h3><p>Although this is a Windows hardening method that is not officially supported (use it at your own risk), when tested and implemented correctly by a DevOps engineer familiar with Infrastructure-as-Code (here are <a href="https://medium.com/wandersick/skills-to-get-equipped-career-wise-amid-covid-19-6228782b0943">freelancing marketplaces</a> to hire one), it is an elegant way to improve productivity and make sure security settings are correctly applied in a way that is less prone to human errors. For home servers or labs that do not require as much consideration, this is a godsend. Thanks!</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2018/04/windows-server-hardening-with-chef.html"><em>https://tech.wandersick.com</em></a><em> on 24 April, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa8095a64cfe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/quick-windows-hardening-with-chef-infrastructure-as-code-aa8095a64cfe">Quick Windows Hardening with Infrastructure-as-Code — Chef and Inspec</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How-to: Create a Silent Installer with AutoHotkey and Publish it on Chocolatey]]></title>
            <link>https://medium.com/wandersick/how-to-create-a-silent-installer-with-autohotkey-and-publish-it-on-chocolatey-8e3a9cf6da70?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/8e3a9cf6da70</guid>
            <category><![CDATA[software-deployment]]></category>
            <category><![CDATA[autohotkey]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[chocolatey]]></category>
            <category><![CDATA[powershell]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Sun, 24 Nov 2019 03:01:58 GMT</pubDate>
            <atom:updated>2021-05-28T12:54:10.746Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Supposed there is a portable Windows application without an installer and uninstaller, how to create them back? In today’s post, we will explore one way to build a Setup.exe using AutoHotkey (AHK), with additional compression of 7-Zip applied to the Setup.exe and remaining files of the portable application for maximum compression, and then wrap it with an outer unattended installer, turning a portable application into an installable one while being suitable also for silent deployment.</p><p>The application example, i.e. the application for which a setup is created is <a href="https://medium.com/wandersick/aerozoom-a-smooth-wheel-zooming-mouse-enhancing-panel-cd2bdc5e6489">AeroZoom</a>. While some terminologies are specific to AeroZoom, the general concepts should apply to other software.</p><pre>// ⭐1️⃣ to be built: outer unattended installer written in AHK<br><br>AeroZoom_Unattended_Installer.exe<br>    │<br>    │   // 2️⃣ to be built: 7-Zip self-extracting archive<br>    │<br>    └───AeroZoom_7-Zip_SFX.exe<br>          │<br>          ├───AeroZoom // portable app example<br>          │<br>          │      AeroZoom.exe<br>          │      ...<br>          │<br>          │      // ⭐3️⃣ to be built: inner setup written in AHK<br>          │<br>          │      Setup.exe<br>          │<br>          └───Data</pre><ol><li>AeroZoom_Unattended_Installer.exe will be the outer unattended installer we will write in <a href="https://autohotkey.com/">AutoHotkey</a> (AHK) language, which contains 7-Zip SFX AeroZoom_7-Zip_SFX.exe and is responsible for extraction as well as calling an inner Setup.exe to install AeroZoom for all users silently</li><li>The second-level AeroZoom_7-Zip_SFX.exe will be our <a href="https://www.7-zip.org/">7-Zip</a> self-extracting archive (SFX). It contains the portable application files of AeroZoom and the inner Setup.exe<br>a) Use of a 7-Zip SFX automatically provides silent extraction parameters for the outer AeroZoom_Unattended_Installer.exe to leverage<br>b) The SFX will be zipped with the ultra compression option to effectively reduce the size of AeroZoom from 32MB to 2MB in the case of AeroZoom which contains multiple similar executables</li><li>The third-level Setup.exe, the inner setup, is the second AutoHotkey program we will write which provides installations parameters for the outer AeroZoom_Unattended_Installer.exe which can be leveraged e.g. by choco install command of Chocolatey, uninstallation parameters for choco uninstall, as well as logic to determine several things such as whether AeroZoom has already been installed, which will be detailed in the last section</li></ol><p>After walking through how to create AeroZoom_7-Zip_SFX.exe and AeroZoom_Unattended_Installer.exe (goal #1), we will take a detour to go through how to push this unattended installer to the community repository of <a href="https://chocolatey.org/">Chocolatey</a> (goal #2), the package manager for Windows, before going back to detailing how to create the inner Setup.exe (goal #3).</p><figure><img alt="Chocolatey — choco install aerozoom" src="https://cdn-images-1.medium.com/max/848/0*GMBU-y3Q5ZK7e0x4.png" /><figcaption>Installing AeroZoom via Chocolatey community repository (goal #2)</figcaption></figure><p>This how-to will be centered around our code repository on GitHub:</p><p><a href="https://github.com/wandersick/az-autohotkey-silent-setup">wandersick/az-autohotkey-silent-setup</a></p><h4>Table of Content</h4><ol><li><a href="#5b22">Step-by-Step: Building Outer Unattended Installer using AutoHotkey</a> (Goal #1)</li><li><a href="#f3b2">Pushing Unattended Installer to Chocolatey</a> (Goal #2)</li><li><a href="#574d">Step-by-Step: Building Inner Setup Using AutoHotkey</a> (Goal #3)</li></ol><p>Let’s go and create all those exe files above!</p><h4>Some Trivia of AeroZoom (before We Begin)</h4><blockquote><em>As you may have seen on Lifehacker and other media, </em><a href="https://medium.com/wandersick/aerozoom-a-smooth-wheel-zooming-mouse-enhancing-panel-cd2bdc5e6489"><em>AeroZoom</em></a><em> magnifier is a free application I created to enhance Windows Magnifier and optionally Sysinternals ZoomIt to enable screen magnification by mouse-wheeling, as well as turning any mouse into a Home-Theater PC/presentation mouse, where zooming and positioning becomes a breeze without a keyboard.</em></blockquote><p>Originally, AeroZoom was built as a portable application. Its Setup.exe was introduced in a later version, v2.0, and the unattended setup AeroZoom_Unattended_Installer.exe, the first outcome of this article, was introduced in v4.0.</p><h3>1. Step-by-Step: <strong>Building Outer Unattended Installer using AutoHotkey</strong></h3><p>This first section walks through how to create the outer unattended installer, AeroZoom_Unattended_Installer.exe, written in AutoHotkey:</p><p>1. In Command Prompt, download or <a href="https://git-scm.com/downloads">git</a> clone <a href="https://github.com/wandersick/az-autohotkey-silent-setup">our code repository</a> to a desired directory e.g. c:\az-autohotkey-silent-setup</p><pre>cd /d c:<br>git clone <a href="https://github.com/wandersick/az-autohotkey-silent-setup.git">https://github.com/wandersick/az-autohotkey-silent-setup.git</a></pre><p>So that the following folder structure is acquired</p><pre>C:\az-autohotkey-silent-setup<br>│   ...<br>│<br>│   // AHK code of the outer unattended installer to be customized<br>│<br>│   AeroZoom_Unattended_Installer.ahk<br>│<br>│   // optional: for use with Compile_AHK II (alternative compiler)<br>│<br>└───AeroZoom_Unattended_Installer.ahk.ini</pre><p>2. Download <a href="https://tech.wandersick.com/p/aerozoom-for-windows-7-magnifier.html#download">AeroZoom</a> and extract it to a desired directory, e.g. C:\AeroZoom</p><pre>C:\AeroZoom<br>│   AeroZoom.exe<br>│   Readme.txt<br>│   Setup.exe<br>│<br>└───Data</pre><p>3. Build an inner Setup.exe using AutoHotkey following <a href="#574d">these instructions in the last section</a> to learn the process, or leave it as is for now and learn how to build it later (recommended for now)</p><ul><li>Ensure Setup.exe is next to AeroZoom</li></ul><pre>C:\AeroZoom<br>│   AeroZoom.exe<br>│   Readme.txt<br>│<br>│   // if you manually build this Setup.exe, replace existing one<br>│   // otherwise, no action is required<br>│<br>│   Setup.exe<br>│<br>└───Data</pre><p>4. Package (compress) the above C:\AeroZoom application directory in a <a href="https://www.wikihow.com/Use-7Zip-to-Create-Self-Extracting-excutables">7-Zip SFX (self-extracting archive)</a></p><ul><li>Optionally, this step can be skipped by leveraging the AeroZoom download, which already comes with an SFX AeroZoom_v4.0.0.7_beta_2.exe after extraction</li><li>Put the SFX file there and rename it as AeroZoom_7-Zip_SFX.exe</li></ul><pre>C:\az-autohotkey-silent-setup<br>│   AeroZoom_Unattended_Installer.ahk<br>│   AeroZoom_Unattended_Installer.ahk.ini<br>│   README.md<br>│   ...<br>│<br>│   // place SFX (containing C:\AeroZoom) built using 7-Zip here<br>│<br>└───AeroZoom_7-Zip_SFX.exe</pre><p>5. Place an icon named AeroZoom_Setup.ico there (optional)</p><pre>C:\az-autohotkey-silent-setup<br>│   AeroZoom_7-Zip_SFX.exe<br>│   AeroZoom_Unattended_Installer.ahk<br>│   AeroZoom_Unattended_Installer.ahk.ini<br>│   README.md<br>│   ...<br>│<br>│   // optionally, place an icon here<br>│<br>└───AeroZoom_Setup.ico</pre><p>6. Edit <a href="https://github.com/wandersick/az-autohotkey-silent-setup/blob/master/AeroZoom_Unattended_Installer.ahk">AeroZoom_Unattended_Installer.ahk</a> and change below C:\az-autohotkey-silent-setup\AeroZoom_7-Zip_SFX.exe to a desired location (no change if directory is the same as the example)</p><p>As shown below, the AutoHotkey source code of AeroZoom_Unattended_Installer.exe is relatively simple. It only contains three lines (excluding comments):</p><pre>; Package an application (e.g. AeroZoom) in 7-Zip SFX<br>; (FYI: the AeroZoom download already comes with an SFX)<br>; Place it in the location specified below<br>; e.g. C:\az-autohotkey-silent-setup\AeroZoom_7-Zip_SFX.exe<br><br>FileInstall, C:\az-autohotkey-silent-setup\AeroZoom_7-Zip_SFX.exe, %A_ScriptDir%\AeroZoom_7-Zip_SFX.exe, 1<br><br>; Silently extract AeroZoom from SFX into the current folder<br><br>RunWait, %A_ScriptDir%\AeroZoom_7-Zip_SFX.exe -o&quot;%A_ScriptDir%&quot; -y<br><br>; Run silent setup command: Setup.exe /programfiles /unattendaz=1<br>; For AeroZoom, these paramters will perform installation:<br>; - silently (/unattendedaz=1)<br>; - to All Users (/programfiles)<br>; Or uninstall in case AeroZoom is found in the target folder<br>; (built into the logic of Setup.exe of AeroZoom)<br><br>RunWait, %A_ScriptDir%\AeroZoom\Setup.exe /programfiles /unattendaz=1</pre><p>7. <a href="https://autohotkey.com/">Download and install AutoHotKey</a> (specify 32-bit in the setup wizard to maximize compatibility of the compiled executables)</p><p>8. To compile the AutoHotkey script as an executable, download and install <a href="https://www.autohotkey.com/board/topic/21189-compile-ahk-ii-for-those-who-compile/">Compile_AHK II</a>.</p><ul><li>While under repository directory (e.g. C:\az-autohotkey-silent-setup), right-click AeroZoom_Unattended_Installer.ahk and select <em>Compile with Options</em> which would parse parameters from <a href="https://github.com/wandersick/az-autohotkey-silent-setup/blob/master/AeroZoom_Unattended_Installer.ahk.ini">AeroZoom_Unattended_Installer.ahk.ini</a></li><li>The ini file has an option named Execution_Level=4 which means requireAdministrator (run as administrator). This is required for the installer to carry out installation successfully.</li><li>While Compile_AHK II comes with compression feature, this article uses 7-Zip as 7-Zip reduces the file size much better (from 32MB to 2MB) in our case.</li></ul><p>Alternatively, the default compiler which comes with AutoHotkey can be used instead of Compile_AHK II if preferred.</p><ul><li>While under repository directory (e.g. C:\az-autohotkey-silent-setup), compile AeroZoom_Unattended_Installer.ahk using the bundled AHk2Exe utility, usually located under C:\Program Files\AutoHotkey\Compiler as so:</li><li>&quot;C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe&quot; /in &quot;AeroZoom_Unattended_Installer.ahk&quot; /icon &quot;AeroZoom_Setup.ico&quot;<br>- Icon parameter is optional: /icon &quot;AeroZoom_Setup.ico&quot;</li><li>For me, I prefer Compile_AHK II than the official compiler in our case where the installer requires “Run as Administrator” rights. Compile_AHK II has built in support of Execution_Levels while the official compiler has <a href="https://stackoverflow.com/questions/43298908/how-to-add-administrator-privileges-to-autohotkey-script/43299069">other means to achieve it</a>.</li></ul><p>To each their own, choose a method with which you are comfortable. If you know of a better way, feel free to let me know!</p><p>9. Done. Now executing AeroZoom_Unattended_Installer.exe would silently trigger an extraction of 7-Zip SFX AeroZoom_7-Zip_SFX.exe and calls the inner AeroZoom Setup.exe to install AeroZoom for all users with its unattended installation parameter /programfiles /unattendAZ=1 (which will be further explained in the third and final section)</p><p><strong>Goal #1</strong>: The end result, AeroZoom_Unattended_Installer.exe, is available for <a href="https://github.com/wandersick/aerozoom/releases/tag/4.0.2">download here</a> (as AeroZoom_v4.0.0.7_beta_2_silent_installer.exe).</p><h4>About False-Positive Notices from Anti-virus Software</h4><p>Like certain AutoHotkey applications, some anti-virus vendors may falsely identify the unattended installer created as undesirable. It is understandable considering the nature of this application is to perform installation and uninstallation in a silent way, which involves seemingly risky tasks such as modifying uninstallation keys in the registry.</p><p>On the other hand, I found that compiling using Compile_AHK II and/or an icon helps lower the detection rates a little bit (from <a href="https://www.virustotal.com/gui/file/e8cf2094a562a5b7010edecb8bdcb11f15ea95ab21bf3ce27e7e58426c3bcf6a/detection">12</a> down to <a href="https://www.virustotal.com/gui/file/015da23376e29da9e7501eaaf9c501fbfd3fce87e5604cd09fbe4cd191537c27/detection">&lt;10</a> out of 65 anti-virus applications on VirusTotal).</p><p>Still, this false-positive detection issue may not be completely eliminated and can be safely ignored. It is recommended to <a href="https://www.techsupportalert.com/content/how-report-malware-or-false-positives-multiple-antivirus-vendors.htm">report your file to your anti-virus vendor as clean if possible</a>.</p><h3>2. Pushing Unattended Installer to Chocolatey</h3><p>Thanks to the below Chocolatey how-to article by Coffmans and <a href="https://chocolatey.org/docs/create-packages">guidance from Chocolatey</a>, I was able to figure out how to push the outer unattended installer to the <a href="https://chocolatey.org/packages/aerozoom">Chocolatey community repository here</a>.</p><p><a href="https://medium.com/@coffmans/my-own-chocolatey-package-for-dessert-f7721b7fe234">My own Chocolatey package for dessert</a></p><p>The Chocolatey package specification files customized for AeroZoom have been included in the <a href="https://github.com/wandersick/az-autohotkey-silent-setup">git repository</a> downloaded in step #1 of the above section which was initially created with choco new &lt;package name&gt; command after Chocolatey has been <a href="https://chocolatey.org/docs/installation">downloaded and installed</a> on a supported Windows machine].</p><p>Let’s walk through the folder structure:</p><pre>C:\az-autohotkey-silent-setup\Chocolatey\AeroZoom<br>│   ReadMe.md<br>│   _TODO.txt<br>│   ...<br>│<br>│   // 1️⃣ package metadata<br>│<br>│   aerozoom.nuspec<br>│<br>└───tools</pre><pre>        // 2️⃣ tasks run before [un]install scripts</pre><pre>        chocolateybeforemodify.ps1</pre><pre>        // 3️⃣ edited Chocolatey install script<br>        //    (for use with &#39;choco install&#39;)</pre><pre>        chocolateyinstall.ps1</pre><pre>        // 4️⃣ edited Chocolatey uninstall script<br>        //    (for use with: &#39;choco uninstall&#39;)</pre><pre>        chocolateyuninstall.ps1</pre><p>1. <a href="https://github.com/wandersick/az-autohotkey-silent-setup/blob/master/Chocolatey/AeroZoom/aerozoom.nuspec">aerozoom.nuspec</a> contains the below self-describing package metadata (click the hyperlink to see the AeroZoom example with comments)</p><ul><li>id</li><li>version</li><li>packageSourceUrl</li><li>owners</li><li>title</li><li>authors</li><li>projectUrl</li><li>iconUrl</li><li>licenseUrl</li><li>requireLicenseAcceptance</li><li>projectSourceUrl</li><li>docsUrl</li><li>mailingListUrl</li><li>bugTrackerUrl</li><li>tags</li><li>summary</li><li>description</li><li>releaseNotes</li></ul><p>2. <a href="https://github.com/wandersick/az-autohotkey-silent-setup/blob/master/Chocolatey/AeroZoom/tools/chocolateybeforemodify.ps1">Chocolateybeforemodify.ps1</a> performs pre-checks prior to installation and uninstallation. For example, to prevent running processes from conflicting with setup, we can use PowerShell cmdlet Stop-Process to forcefully terminate processes</p><ul><li>I learned it is important to add -ErrorAction SilentlyContinue so that users do not see error texts when the command runs without any process to stop</li></ul><pre>Stop-Process -ProcessName aerozoom* -Force -ErrorAction SilentlyContinue</pre><p>3. <a href="https://github.com/wandersick/az-autohotkey-silent-setup/blob/master/Chocolatey/AeroZoom/tools/chocolateyinstall.ps1">chocolateyinstall.ps1</a> performs silent installation by downloading and using an unattended installer, which is the outcome from the first section of this article. It should be hosted on a publicly accessible web server in order for this Chocolatey installation script to leverage</p><pre>$url = &#39;https://github.com/wandersick/aerozoom/releases/download/4.0.2/AeroZoom_v4.0.0.7_beta_2_silent_installer.exe&#39;</pre><p>4. <a href="https://github.com/wandersick/az-autohotkey-silent-setup/blob/master/Chocolatey/AeroZoom/tools/chocolateyuninstall.ps1">chocolateyuninstall.ps1</a> performs silent uninstallation by using a parameter specific to the application installer, which is /programfiles /unattendAZ=1 in the case of AeroZoom. (The parameters will be further explained in the third and final section)</p><pre>silentArgs = &quot;/programfiles /unattendAZ=1&quot;</pre><p>One AeroZoom-specific side-note:</p><ul><li>Due to the way Setup.exe of AeroZoom works, for chocolateyuninstall.ps1, I have added Substring (from PowerShell) to remove /programfiles /unattendAZ=2 from UninstallString (in Windows registry), replacing it with /programfiles /unattendAZ=1 from $silentArgs (in chocolateyuninstall.ps1). Otherwise, uninstallation would not be performed in an unattended way</li></ul><pre>$packageArgs[&#39;file&#39;] = &quot;$($_.UninstallString)&quot;.Substring(0, $_.UninstallString.IndexOf(&#39; /&#39;))</pre><p>In addition, below are the commands for packaging, testing (installing and uninstalling), as well as pushing to the Chocolatey community repository</p><pre># create NuGet package (aerozoom.4.0.0.7.nupkg)<br># ensure current directory is correct</pre><pre>cd az-autohotkey-silent-setup\Chocolatey\AeroZoom<br>choco pack</pre><pre># install aerozoom.4.0.0.7.nupkg by running:<br># - chocolateybeforemodify.ps1<br># - chocolateyinstall.ps1</pre><pre>choco install aerozoom.4.0.0.7.nupkg</pre><pre># uninstall aerozoom by running:<br># - chocolateybeforemodify.ps1<br># - chocolateyuninstall.ps1</pre><pre>choco uninstall aerozoom</pre><pre># push to community repo (--api-key required)</pre><pre>choco push aerozoom.4.0.0.7.nupkg</pre><p><a href="https://chocolatey.org/packages/aerozoom">AeroZoom</a></p><p><strong>Goal #2</strong>: Having gone through the <a href="https://chocolatey.org/faq#how-does-the-moderation-review-process-work">moderation review process</a>, AeroZoom is available on Chocolatey community repository via the link above now.</p><h3>wandersick on Twitter</h3><p>AeroZoom can now be installed via Chocolatey repository: &quot;choco install aerozoom&quot; https://t.co/ai8s3WvJM7</p><h3>3. Step-by-Step: Building Inner Setup Using AutoHotkey</h3><p>This final section walks through how to create the inner Setup.exe acquired after 7-Zip extraction.</p><p>The steps for building the Setup.exe would be:</p><ol><li>First, let’s delete Setup.exe in the AeroZoom folder</li><li>If not already done so, the files below can be <a href="https://gallery.technet.microsoft.com/AeroZoom-The-smooth-wheel-e0cdf778">downloaded here</a> and extracted to a desired directory, e.g. C:\AeroZoom</li></ol><pre>C:\AeroZoom<br>│   AeroZoom.exe<br>│   Readme.txt<br>│   ...<br>│<br>│   // Setup.exe will be built using below method here<br>│<br>└───Data</pre><p>2. Acquire the source code of Setup.exe, i.e. <a href="https://github.com/wandersick/az-autohotkey-silent-setup/blob/master/Setup.ahk">Setup.ahk</a></p><p>If not already done so, open Command Prompt, download or git clone <a href="https://github.com/wandersick/az-autohotkey-silent-setup">our code repository</a> to a desired directory e.g. c:\az-autohotkey-silent-setup</p><pre>cd /d c:<br>git clone https://github.com/wandersick/az-autohotkey-silent-setup.git</pre><p>So that the following folder structure is acquired</p><pre>C:\az-autohotkey-silent-setup<br>│   Setup.ahk.ini<br>│   ...<br>│<br>│   // source code of Setup.exe of AeroZoom<br>│<br>└───Setup.ahk</pre><p>3. If not already done so, <a href="https://autohotkey.com/">download and install AutoHotKey</a> (specify 32-bit in the setup wizard to maximize compatibility of the compiled executables)</p><p>4. To compile the AutoHotkey script into an executable, download and install <a href="https://www.autohotkey.com/board/topic/21189-compile-ahk-ii-for-those-who-compile/">Compile_AHK II</a>.</p><ul><li>While under repository directory (e.g. C:\az-autohotkey-silent-setup), right-click Setup.ahk and select <em>Compile with Options</em>, which would parse parameters from <a href="https://github.com/wandersick/az-autohotkey-silent-setup/blob/master/Setup.ahk.ini">Setup.ahk.ini</a></li><li>The ini file contains Execution_Level=3 which means highestAvailable (run with highest privileges available) instead of requireAdministrator (run as administrator) as the Setup.ahk supports dynamically installing into current user profile (when no administrator rights are available) or installing into system directory e.g. C:\Program Files (x86) (when administrator rights are available and Setup.exe /programfiles is specified)</li></ul><p>5. Done</p><p><strong>Goal #3</strong>: The end result, Setup.exe, can be used to install and uninstall AeroZoom, provided that it is located in the below directory, and that suitable unattended installation parameters are passed (see Setup.exe /?), or the installation is performed in an normal attended way (i.e. double-clicking the Setup.exe and follow the on-screen installation instructions).</p><pre>C:\AeroZoom<br>│   AeroZoom.exe<br>│   Readme.txt<br>│   ...<br>│<br>│   // Place the newly created Setup.exe in this folder<br>│   // It can install and uninstall AeroZoom here<br>│   Setup.exe<br>│<br>└───Data</pre><p>If you would like, you may also continue from step 3 of the first section to leverage this newly created Setup.exe to create the outer unattended installer again, which enables a totally silent installation experience of AeroZoom without the need to supply any parameters.</p><h4>How It Works</h4><p>Instead of using a popular approach such as Windows Installer, AeroZoom implements Setup.exe from the ground up, which has its own parameters:</p><ul><li>/programfiles for installing into C:\Program Files (x86) (or C:\Program Files for 32-bit OS) instead of current user profile, i.e. %localappdata%, usually C:\Users\{username}\AppData\Local</li><li>/unattendAZ=1 for an unattended installation</li></ul><p>If it detects AeroZoom is already installed, the setup will perform an uninstallation instead</p><ul><li>If /unattendAZ=2 or any other values, an uninstallation dialog box will also be prompted</li></ul><pre>targetDir=%localappdata%<br>If %1% {<br>  <br>  ; For each parameter</pre><pre>  Loop, %0%<br>  {<br>    ; Retrieve A_Index variable contents</pre><pre>    param := %A_Index%<br>    If (param=&quot;/unattendAZ=1&quot;)<br>      unattendAZ=1<br>    Else if (param=&quot;/unattendAZ=2&quot;)<br>      unattendAZ=2<br>    Else if (param=&quot;/programfiles&quot;)<br>    {<br>      targetDir=%programfiles%<br>      setupAllUsers=1<br>    }<br>    Else<br>    {<br>      Msgbox, 262192, AeroZoom Setup, Supported parameters:`n`n - Unattended setup : /unattendAZ=1`n - Install for all users : /programfiles`n`nFor example: Setup.exe /programfiles /unattendaz=1`n`nNote:`n - If setup finds a copy in the target location, uninstallation will be carried out instead.`n - If you install into Program Files folder, be sure you&#39;re running it with administrator rights.<br>      ExitApp, 5<br>    }<br>  }<br>}</pre><p>During installation or uninstallation, Setup.exe would first check a few prerequisites, such as whether files it depends on exist or not, as well as terminating any executables that could be running.</p><p>Once it is OK to proceed with installation, Setup.exe would create shortcuts:</p><pre>IfExist, %targetDir%\wandersick\AeroZoom\AeroZoom.exe<br>{<br>  ; Create shortcut to Start Menu (All Users)</pre><pre>  If setupAllUsers<br>  {<br>    FileCreateShortcut, %targetDir%\wandersick\AeroZoom\AeroZoom.exe, %A_ProgramsCommon%\AeroZoom.lnk, %targetDir%\wandersick\AeroZoom\,, AeroZoom`, the smooth wheel-zooming and snipping mouse-enhancing panel,,<br>    FileCreateShortcut, %targetDir%\wandersick\AeroZoom\AeroZoom.exe, %A_DesktopCommon%\AeroZoom.lnk, %targetDir%\wandersick\AeroZoom\,, AeroZoom`, the smooth wheel-zooming and snipping mouse-enhancing panel,,<br>  }<br>  ; Create shortcut to Start Menu (Current User)</pre><pre>  Else<br>  {<br>    FileCreateShortcut, %targetDir%\wandersick\AeroZoom\AeroZoom.exe, %A_Programs%\AeroZoom.lnk, %targetDir%\wandersick\AeroZoom\,, AeroZoom`, the smooth wheel-zooming and snipping mouse-enhancing panel,,<br>    FileCreateShortcut, %targetDir%\wandersick\AeroZoom\AeroZoom.exe, %A_Desktop%\AeroZoom.lnk, %targetDir%\wandersick\AeroZoom\,, AeroZoom`, the smooth wheel-zooming and snipping mouse-enhancing panel,,<br>  }<br>}</pre><p>Next, Setup.exe would write uninstallation information such as UninstallString to the Windows Registry:</p><pre>If setupAllUsers<br>{<br>  ; If AeroZoom was installed for all users<br>  <br>  RegWrite, REG_SZ, HKEY_CURRENT_USER, %regKey%, UninstallString, %targetDir%\wandersick\AeroZoom\Setup.exe /unattendAZ=2 /programfiles<br>}<br>Else<br>{<br>  ; If AeroZoom was installed for current user</pre><pre>  RegWrite, REG_SZ, HKEY_CURRENT_USER, %regKey%, UninstallString, %targetDir%\wandersick\AeroZoom\Setup.exe /unattendAZ=2<br>}</pre><p>Other information it writes there are:</p><ul><li>Publisher</li><li>DisplayVersion</li><li>InstallLocation</li><li>URLInfoAbout</li><li>HelpLink</li><li>InstallDate</li><li>DisplayName</li><li>DisplayIcon</li><li>EstimatedSize</li></ul><p>Regarding uninstallation, it is simply the above process in reverse, i.e. deleting shortcuts and removing the registry entries.</p><p>One thing worth mentioning is previous version of AeroZoom installer (v4.0 and before) would leave Setup.exe under the installation directory. Since v5.0, this has been solved by calling a minimized cmd.exe /c to ping localhost followed by the self-destruction, in order for Setup.exe to delete itself.</p><pre>; Remove directory content including Setup.exe that is running<br>; after 3 seconds using ping in a minimized Command Prompt</pre><pre>Run, cmd /c start /min ping 127.0.0.1 -n 3 &gt;nul &amp; rd /s /q &quot;%targetDir%\wandersick\AeroZoom&quot;</pre><p>That’s it.</p><p>For simplicity, only the essential parts of Setup.exe are described above. Things that are specific to AeroZoom (e.g. removing scheduled tasks that AeroZoom may have created if specified by user) are not mentioned. For the rest, please refer to the comments in the <a href="https://github.com/wandersick/az-autohotkey-silent-setup/blob/master/Setup.ahk">source code file</a> Setup.ahk and the comments inside.</p><p>It would be my pleasure if you find this article informative. Welcome to comment if you have any question or suggestion. Have a nice day!</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2019/07/how-to-create-silent-installer-with.html"><em>https://tech.wandersick.com</em></a><em> </em>on July 14, 2019.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e3a9cf6da70" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/how-to-create-a-silent-installer-with-autohotkey-and-publish-it-on-chocolatey-8e3a9cf6da70">How-to: Create a Silent Installer with AutoHotkey and Publish it on Chocolatey</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DIY Your Own Easy-to-Use Encrypted Portable Disk Based on VeraCrypt/TrueCrypt]]></title>
            <link>https://medium.com/wandersick/tcrypt2go-vcrypt2go-diy-your-own-easy-to-use-encrypted-portable-disk-based-on-veracrypt-178045e1b0ac?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/178045e1b0ac</guid>
            <category><![CDATA[truecrypt]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[usb-drives]]></category>
            <category><![CDATA[encryption-software]]></category>
            <category><![CDATA[veracrypt]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Sun, 04 Aug 2019 12:57:10 GMT</pubDate>
            <atom:updated>2026-10-11T13:30:59.677Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>DIY Your Own Easy-to-Use Encrypted Portable Disk — Simplify VeraCrypt with vCrypt2Go</h3><p>Are you a security-aware person? Have you got a USB thumb drive or external hard drive you wish to use that does not have any built-in encryption features? You could turn it into one that does, with the cross-platform open-source alternative to BitLocker — TrueCrypt, succeeded by VeraCrypt — but it is not as easy or intuitive to unlock or use as a purchased encrypted external storage solution in the market, because of its feature-rich nature; unlocking is done via an advanced user interface that is more meant for the technically inclined.</p><p><strong>[Go to </strong><a href="https://tech.wandersick.com/2018/02/introducing-tcrypt2go-and-vcrypt2go.html#download"><strong>Download</strong></a><strong>]</strong></p><h3>Solution — vCrypt2Go and tCrypt2Go, Lock-and-Unlock Utilities, to Simplify and Speed Up Drive Unlocking</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/0*XaIP5X1xpeqFKujP" /></figure><p>Named after VeraCrypt and ‘BitLocker To Go’, vCrypt2Go — a set of open-source and cross-platform lock-and-unlock utilities on top of VeraCrypt enabling users to DIY their own encrypted portable storage which is simple to use as a purchased solution in the market — simplifies the user experience of VeraCrypt Portable on removable media/external hard disks by hiding the complexities of VeraCrypt and its options from users, making it easy to lock and unlock an encrypted USB thumb drive or hard disk with as few steps as possible.</p><p>(Likewise, the same applies for the predecessor of VeraCrypt — TrueCrypt — after which tCrypt2Go is named.)</p><h3>List of Features</h3><ul><li>Optimize use of portable drives encrypted by TrueCrypt and VeraCrypt</li><li>Easily unlock and lock portable drives with a simplified process, hiding complexities from users<br>- To unlock, double-click ‘unlock’, enter password in a simple user interface, then the unlocked drive is presented to the user; to lock, double-click ‘lock’, no further action required<br>- Easily identify executable icons which look like a lock (unlocked or locked)</li><li>A set of step-by-step installation guides available for encrypting different types of portable drives</li><li>Supports both encrypted partitions and containers (virtual disk files)</li><li>Handles different scenarios — admin or standard user account; with or without TrueCrypt/VeraCrypt preinstalled</li><li>Portable and cross-platform — Windows and Mac OS X (beta)</li><li>Automatic User Account Control elevation to highest privileges available on Windows Vista and later</li></ul><p>(Refer to <a href="https://wandersick.blogspot.com/2018/02/technical-overview-how-tcrypt2go-and.html">Technical Overview</a> article for limitations.)</p><h3>Seeing It in Action</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*osJWAW9iDEJxMTXp" /></figure><p>As demonstrated, the goal of tCrypt2Go/vCrypt2Go is to make it seamless and convenient for users to secure and use their portable drive with the provided set of lock-and-unlock utilities. There will be no dialog shown to users other than entering the password for unlocking the protected area (which is a virtual disk file, or container, in the case of a USB thumb drive of removable media type as demonstrated below, or a partition in the case of an external hard disk of a fixed disk type). It works on Windows (stable) and Mac (beta) depending on which file system is chosen (FAT32, NTFS, exFAT) for formatting the protected partition. (For further details, read the Technical Overview article.)</p><h3>Requirements</h3><ul><li>Hardware: Any unused portable storage (e.g. USB thumb drives, memory cards, external hard disks…)</li><li>Operating System: Any Windows and Mac operating systems supported by TrueCrypt and VeraCrypt, including Windows XP and later, Mac OS 10.6.5 (10.7 for VeraCrypt) and later<br>- tCrypt2Go and vCrypt2Go on Windows are stable, but for Mac OS X they are currently in beta as they have yet to be tested in newer OS X versions</li></ul><h3>Getting Started</h3><p>If you are a user who has been offered a USB drive with tCrypt2Go or vCrypt2Go utilities, read the User Guide below to understand how to use it. Put simply, double-click ‘unlock’, enter password, done; to lock, double-click ‘lock’, done.</p><p>If you are looking for how to set up a drive for use with tCrypt2Go or vCrypt2Go, read ones of the Installation Guides below. There are two options depending on whether you have a <strong>thumb drive</strong> or a <strong>hard disk</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*mDmjhnVRVsz7aMOG" /></figure><p>To learn more about the technical details behind, read the Technical Overview article. Otherwise, feel free to skip to the Installation Guides to implement immediately.</p><h3>List of Articles on tCrypt2Go/vCrypt2Go</h3><ul><li><strong>*You Are Here*</strong> Introducing tCrypt2Go and vCrypt2Go — Lock-and-Unlock Utilities for TrueCrypt and VeraCrypt Portable</li><li><a href="https://tech.wandersick.com/2018/02/technical-overview-how-tcrypt2go-and.html">Technical Overview — How tCrypt2Go and vCrypt2Go work</a></li><li><a href="https://tech.wandersick.com/2018/02/installation-guide-setting-up-tcrypt2go_26.html">Installation Guide — Setting up tCrypt2Go and vCrypt2Go to Encrypt Portable Hard Disks</a></li><li><a href="https://tech.wandersick.com/2018/02/installation-guide-setting-up-tcrypt2go.html">Installation Guide — Setting up tCrypt2Go and vCrypt2Go to Encrypt USB Thumb Drives</a></li><li><a href="https://tech.wandersick.com/2018/02/user-guide-how-to-unlock-and-lock.html">User Guide — How to Unlock and Lock Encrypted Drives using tCrypt2Go or vCrypt2Go</a></li><li><a href="https://tech.wandersick.com/2018/02/enhancing-and-troubleshooting-common.html">Enhancing and Troubleshooting Common Issues with tCrypt2Go or vCrypt2Go</a></li></ul><h3>Download</h3><p>The compiled executables of tCrypt2Go and vCrypt2Go can be downloaded at its <a href="https://tech.wandersick.com/2018/02/introducing-tcrypt2go-and-vcrypt2go.html#download">homepage</a>.</p><h3>Open Source</h3><p>Source Code of <a href="https://github.com/wandersick/tcrypt2go">tCrypt2Go</a> and <a href="https://github.com/wandersick/vcrypt2go">vCrypt2Go</a> are also available on GitHub.</p><h3>Release History</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*LwiIuVxAFCmBmztiBzt3_Q.png" /></figure><p>Hope this article or the tool is useful to you. 😊</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2018/02/introducing-tcrypt2go-and-vcrypt2go.html"><em>https://tech.wandersick.com</em></a><em> </em>on February 26, 2018.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=178045e1b0ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/tcrypt2go-vcrypt2go-diy-your-own-easy-to-use-encrypted-portable-disk-based-on-veracrypt-178045e1b0ac">DIY Your Own Easy-to-Use Encrypted Portable Disk Based on VeraCrypt/TrueCrypt</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChMac — Windows Command to Change MAC Addresses of Network Adapters]]></title>
            <link>https://medium.com/wandersick/chmac-windows-command-to-change-mac-addresses-of-network-adapters-chmac-bat-54e68c00c85?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/54e68c00c85</guid>
            <category><![CDATA[network-security]]></category>
            <category><![CDATA[mac-address]]></category>
            <category><![CDATA[wi-fi-network]]></category>
            <category><![CDATA[windows-networking]]></category>
            <category><![CDATA[batch-script]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Sun, 21 Jul 2019 14:56:58 GMT</pubDate>
            <atom:updated>2026-10-11T13:31:15.539Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>ChMac — Windows Command to Change MAC Addresses of Network Adapters</h3><p>Named after getmac and chmod, chmac is a command-line-interface (CLI) tool for Windows that changes or randomizes MAC addresses of specified network adapters, e.g. for a client device to reuse public Wi-Fi hotspot that has exceeded usage limit for the day, or to enhance security.</p><p>An easy-to-use interactive console is available, alongside command-line parameters, e.g. for scheduling jobs with Task Scheduler. ChMac also has built-in support for recurrence.</p><p><strong>[Go to </strong><a href="https://tech.wandersick.com/2019/06/chmac-windows-command-to-change-mac.html#download"><strong>Download</strong></a><strong>]</strong></p><p>Also on Chocolatey: choco install chmac / winget: winget install chmac</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/0*k9_cKglzkB2WwMuq.gif" /></figure><p>For a quick start, refer to Examples section below; for screenshots, refer to Screenshots section.</p><h3>List of Features</h3><ul><li>Change MAC addresses on Windows automatically or manually<br>- Automatically change MAC addresses on set intervals<br>- Useful to reconnect to free public Wi-Fi hotspots that impose a time limit by recognizing MAC addresses to prevent the same device from reconnecting</li><li>Randomize MAC addresses for better security using public Wi-Fi<br>- Generate new MAC addresses randomly based on a customizable list of organizationally unique identifiers (OUI)</li><li>Optionally leverage DevCon.exe to simply the process by automatically disabling and re-enabling network interface card (NIC)<br>- ChMac also works without DevCon by showing the Network Connections folder when finished, so that users can manually disable and re-enable NIC for new settings to take effect<br>- On first launch, users are guided to download DevCon with convenient automatic and manual options</li><li>Error checking and rich return codes for scripting and other possibilities</li><li>Free and open-source software written in Windows batch language</li><li>Portable by default. Optional installer enables chmac command globally (in Command Prompt and Run prompt. For PowerShell, the command would be chmac.bat)</li><li>Supports Windows 2000/XP/Vista/8/10 and Server 2003/2008/2012/2016/2019</li><li>Easy-to-use interactive console as well as accepting command-line parameters<br>- Just follow instructions on screen for using the interactive console. For command-line mode, see the following</li></ul><h3>How It Works</h3><p>ChMac works by querying a list of network adapters from Windows registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}.</p><p>Based on user selection, ChMac updates the registry key responsible for the MAC address, NetworkAddress, of the corresponding adapter with an inputted or randomized MAC address from customizable OUI lists, either ad-hoc or automatically with Task Scheduler or its built-in auto-changing mechanism.</p><p>After MAC address is updated, the network adapter will be automatically disabled and re-enabled if an OS-specific DevCon.exe (a separate download from Microsoft) is available in the OS (the environmental variable, PATH) or under ChMac dependency directory, ChMac\Data\3rdparty. For more details, refer to <a href="https://github.com/wandersick/chmac#Dependencies">Dependencies</a> section.</p><p>If DevCon is unavailable, the Network Connections window will be presented to user where network adapter can be disabled and re-enabled manually.</p><h3>Syntax</h3><p>chmac.bat [/d dir][/l][/m address][/n id][/r][/help][/?]</p><h3>Parameters</h3><pre>/d dir        :: working directory - maybe required<br>                 (MUST be specified before other parameters)<br>/l            :: list network adapters and their IDs<br>/m            :: new mac address to be applied.<br>/n            :: adapter to be applied new mac address if /m is unspecified<br>                 new mac address will be randomized (OUI kept) and automatically filled in<br>/r            :: restore to original MAC address<br>/a            :: auto-change interval<br>                 suffix may be s for seconds, m for minutes, h for hours or d for days<br>                 e.g. enter &#39;20m&#39; to recur every 20 mins. [X] to reset or exit</pre><p>When no parameter is specified, interactive mode is entered on launch.</p><h3>MAC Address Format</h3><p>The MAC address format can be any of the following:</p><pre>AB-CD-EF-12-34-56<br>AB:CD:EF:12:34:56<br>AB.CD.EF.12.34.56<br>AB CD EF 12 34 56            :: without any separation in between at all</pre><p><strong>Note</strong>: To increase success rate of changing MAC addresses in Windows Vista and later OS, the OUI lists included in ChMac contains MAC addresses which starts with 02 only</p><h3>Examples</h3><h4>Command-Line Mode</h4><pre>chmac /l                     :: list available adapter IDs<br>chmac /n 1                   :: update network adapter #1 with randomized mac address numbers<br>chmac /m 00301812AB01 /n 2   :: update network adapter #2 with the new mac address: 00-30-18-12-AB-01<br>chmac /n 3 /r                :: restore adapter 3 to its original MAC<br>chmac /n 4 /a 20m            :: auto-change MAC per 20 minute<br>chmac /?                     :: shows short help. [/help] for long</pre><h4>Interactive Mode</h4><p>Simply run chmac.bat and follow on-screen instructions.</p><h3>File Structure</h3><pre>ChMac                      :: Main directory<br>│   chmac.bat              :: Main script<br>│   Setup.exe              :: Optional installer <br>│                             enabling chmac command globally<br>│                             (in Command Prompt and Run prompt)<br>│   Readme.txt             :: Documentation<br>│<br>└───Data<br>    │   OUI_NT5.txt        :: Customizable list of OUIs<br>    │                      :: for Windows XP/2003 and earlier<br>    │   OUI_NT6.txt        :: Customizable list of OUIs<br>    │                      :: for Windows Vista and later<br>    │   _choiceMulti.bat   :: Sub-script by wandersick<br>    │                      :: fallback for OS without choice.exe<br>    │   _choiceYN.bat      :: Sub-script by wandersick<br>    │                      :: fallback for OS without choice.exe<br>    │<br>    └───3rdparty           :: Dependencies put to the top of PATH<br>        │                  :: Higher priority than system PATH <br>        │   grep.exe       :: GNU Linux utility included<br>        │   libeay32.dll   :: GNU Linux library included<br>        │   libiconv2.dll  :: GNU Linux library included<br>        │   libintl3.dll   :: GNU Linux library included<br>        │   libssl32.dll   :: GNU Linux library included<br>        │   sed.exe        :: GNU Linux utility included<br>        │   sleep.exe      :: GNU Linux utility included<br>        │   tr.exe         :: GNU Linux utility included<br>        │   wc.exe         :: GNU Linux utility included<br>        │   wget.exe       :: GNU Linux utility included<br>        │   which.exe      :: GNU Linux utility included<br>        │   devcon.exe     :: Optional: place OS-specific devcon.exe<br>        │<br>        └───LP             :: Dependencies put to the bottom of PATH<br>                           :: Lower priority than system PATH<br>                Readme.txt :: Reminders for LP directory<br>                choice.exe :: Optional: included in OS since Vista<br>                getmac.exe :: Optional: included in OS since XP/2003<br>                reg.exe    :: Optional: included in OS since XP/2003</pre><h3>OUI Files</h3><p>OUI (organizationally unique identifier) files are available in ChMac. Add desired OUIs there for randomization while using the [G] command to generate a new MAC address.</p><ul><li>Not all OUIs work — begin with 02 for a higher success rate on Windows Vista or later.</li><li>For technical details, see: <a href="http://blog.technitium.com/2011/05/tmac-issue-with-wireless-network.html">http://blog.technitium.com/2011/05/tmac-issue-with-wireless-network.html</a></li></ul><p>Filenames:</p><ul><li>OUI_NT5.txt - for Windows 2000, XP and 2003</li><li>OUI_NT6.txt - for Windows Vista and later</li></ul><p>File Content (Default):</p><pre>Vendor=OUI<br>3Com=020475<br>Atheros=021374<br>Broadcom=020AF7<br>Cisco=020D28<br>Intel=020CF1<br>Linksys=020E08<br>Bigfoot=021903<br>Marvell=025043<br>NVIDIA=02044B<br>Realtek=02E04C<br>VIA=02127B</pre><h3>Step-by-Step Screenshots</h3><h4>Command-Line Mode</h4><p>Display short help — chmac /?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/0*yMgXo3ofzJ082Tw7.png" /></figure><p>1: List available network adapters — chmac /l</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/0*dEKRvxgiAWoyWwEM.png" /></figure><p>2: Change MAC address of adapter #6 with a random MAC address — chmac /n 6</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/0*sYf_r_lxjsPtyYMi.png" /></figure><p>3: In case DevCon.exe is unavailable, Network Connections window will automatically be presented where user can manually disable and re-enable adapter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/0*lrQCZnJayFFXQ6V7.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/0*DOBmyKKZv92WP11N.png" /></figure><p>The above is only needed if DevCon.exe unavailable. Refer to Dependencies section below for more information.</p><p>4: MAC address successfully changed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/0*bYeQRuuL39247a3b.png" /></figure><h4>Interactive Mode</h4><p>5: Interactive mode (with an additional option for auto-changing) — chmac.bat</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/0*GMeK4ftCpDEtqjxM.png" /></figure><p>6: Interactively configure auto-changing interval with a 20-min interval — 20m</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*uk1kyy2Nk7m4kfDc.png" /></figure><p>7: Afterwards, select adapter #6 so that its MAC address is auto-changed every 20 mins — 6</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*PzKp-QSqU7XSDVay.png" /></figure><p>8: MAC address successfully changed and waiting for next auto-changing cycle</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*EyN0EGvkiXy92VZV.png" /></figure><p>9 (Bonus): Press R after choosing an adapter (while not in auto-changing mode) to restore original MAC address — R</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/0*42INjneW0X19J2cw.png" /></figure><p>Likewise, if required, press O to edit OUI lists using system-default text editor.</p><h3>Requirements</h3><p>All Windows operating systems from Windows 2000 and up (Windows 10 1809 at the moment) are supported.</p><ul><li>To use this in Windows 2000 or some minimal Windows PE, place these files from another machine which runs English Windows XP or 2003: msvcp60.dll as well as getmac.exe and reg.exe into ChMac\Data\3rdparty\LP.</li></ul><h3>Admin Rights</h3><p>Admin rights are required for editing MAC addresses, disabling and re-enabling network adapters.</p><ul><li>ChMac does not automatically elevate itself if there is no admin rights. Although there is error checking mechanism for being non-admin, it would be better to make sure admin rights are available before executing ChMac</li></ul><h3>Dependencies</h3><p>ChMac wraps around DevCon (optional), Windows-native and GNU Linux utilities</p><p>All of the below dependencies are either optional or do not require attention, as most of them are included already.</p><ul><li>Optionally enhances ChMac using DevCon.exe, Microsoft Windows Device Console which can be downloaded during first launch of the script<br>- Beware of the version to download as there are lots of DevCon versions for different OS. See <a href="https://superuser.com/a/1099688/112570">https://superuser.com/a/1099688/112570</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/0*QtrE9Y1pXEgTaH59.png" /></figure><ul><li>Unix utilities leveraged by ChMac are included already: tr.exe, sed.exe, which.exe, sleep.exe, wc.exe, wget.exe, grep.exe</li><li>Other OS built-in dependencies natively in Windows since Windows XP: getmac.exe, reg.exe, msvcp60.dll</li><li>Optional OS built-in dependency natively in Windows since Windows Vista: choice.exe, automatically falling back to set /p if unavailable or when there are more than 8 network adapters, thru a sub-script, _choiceMulti.bat - <a href="https://github.com/wandersick/ws-choice">https://github.com/wandersick/ws-choice</a><br>- choice.exe may be put here to enhance experiences in OS earlier than Windows Vista or Server 2003<br>- Do not copy choice.exe from Windows Vista or later but the one in Windows Server 2003 or Windows Resource Kit (9x/NT)</li></ul><p>Notes</p><ul><li>getmac.exe and reg.exe should be put inside ChMac\Data\3rdparty\LP (low priority) so that they do not override the version in the OS when a better version is available natively thru the OS</li><li>Other executables should be put inside ChMac\Data\3rdparty (high priority) so that they override the version in the OS in case one is available natively thru the OS</li></ul><h3>Return Codes / Error Messages</h3><h4>Return code: 0</h4><ul><li>Cause: Success</li></ul><h4>Return code: 1</h4><ul><li>Cause: Failure</li></ul><h4>Return code: 3</h4><ul><li>Cause: NIC error</li></ul><p>Messages</p><ul><li>Error: No network adapter found</li><li>Error: Adapter in a nonoperational state</li><li>Error: Adapter unplugged. Please connect first</li></ul><h4>Return code: 4</h4><ul><li>Cause: Bad syntax</li></ul><p>Messages (and related parameters)</p><ul><li>Syntax Error: Working directory (/d)</li><li>Syntax Error: Wrong address length (/m)</li><li>Syntax Error: Not hexadecimal (/m)</li><li>Syntax Error: Not digit (/n)</li><li>Syntax Error: Not digit or smhd (/a)</li><li>Syntax Error: Working directory (/d)</li><li>Syntax Error: Missing parameter /n (/m)</li><li>Syntax Error: Please use “/” instead of ‘-’</li><li>Syntax Error: Unknown parameter</li><li>Syntax Error: Adapter ID unavailable (/n)</li></ul><h4>Return code: 5</h4><ul><li>Cause: No exe is found</li></ul><p>Messages</p><ul><li>Error: No reg.exe. Place one from Windows in “ChMac\Data\3rdparty\LP”</li><li>Error: No getmac.exe. Place one from Windows in “ChMac\Data\3rdparty\LP”</li></ul><h4>Return code: 7</h4><ul><li>Cause: No admin rights</li></ul><p>Messages</p><ul><li>Error: No admin right. Please run as admin</li></ul><h3>Limitations</h3><ol><li>Some virtual adapters may be unsupported</li><li>Randomization logic randomizes numbers (0–9) instead of hexadecimal (0–9, A-F)</li></ol><h3>Download / Installation Options</h3><p>For download of the latest version, go to the <a href="https://tech.wandersick.com/2019/06/chmac-windows-command-to-change-mac.html#download">ChMac homepage</a>.</p><p>After downloading and extracting ChMac.zip, ChMac.bat portable application can be used immediately. Alternatively, Setup.exe (optional) provides installation into Current User or All Users location. For enterprise deployment, a silent installer is also available.</p><p>For users of <a href="https://chocolatey.org/packages/chmac">Chocolatey</a> andwinget repositories who prefers unattended installation into All Users location:</p><ul><li>choco install chmac</li><li>winget install chmac</li></ul><p>*Note for winget users: Please ignore the <a href="https://live.staticflickr.com/65535/49987155847_d781799e16_o.gif">warning from SmartScreen</a>, where you may safely click ‘more info’ to complete installation.</p><h3>Word of Mouth</h3><p>Below is one of the kind comments left by ChMac users. (Thanks!)</p><ul><li>“<a href="https://web.archive.org/web/20191015233441/https://twitter.com/NassimSpace/status/1184248919649411073">Will keep this one handy!</a>”</li></ul><h3>Release History</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eo1Z7yzFK_4WNM0YISowHg.png" /></figure><p>Hope this article or the tool is useful to you. 😊</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2019/06/chmac-windows-command-to-change-mac.html"><em>https://tech.wandersick.com</em></a><em> on June 30, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54e68c00c85" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/chmac-windows-command-to-change-mac-addresses-of-network-adapters-chmac-bat-54e68c00c85">ChMac — Windows Command to Change MAC Addresses of Network Adapters</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SAN Storage Failover and Failback PowerShell Scripts for Failover Cluster]]></title>
            <link>https://medium.com/wandersick/san-storage-failover-and-failback-powershell-scripts-for-failover-cluster-e-g-13d42cc6f6db?source=rss----ef8444397f30---4</link>
            <guid isPermaLink="false">https://medium.com/p/13d42cc6f6db</guid>
            <category><![CDATA[storage-area-network]]></category>
            <category><![CDATA[hyper-v]]></category>
            <category><![CDATA[powershell]]></category>
            <category><![CDATA[failover-cluster]]></category>
            <category><![CDATA[windows-server]]></category>
            <dc:creator><![CDATA[wandersick]]></dc:creator>
            <pubDate>Sun, 21 Jul 2019 14:55:05 GMT</pubDate>
            <atom:updated>2026-10-11T13:31:20.487Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Storage Failover and Failback PowerShell Scripts for Failover Cluster with an Interactive Console Menu</h3><blockquote>General storage failover and failback PowerShell template for Failover Cluster (e.g. Hyper-V) with an easy-to-use interactive console menu</blockquote><p>Note: This is a template to ease development. The storage-vendor-specific part of the scripts have to be coded by yourself. An alternative way is to engage professionals to develop the script on one of the <a href="https://medium.com/wandersick/skills-to-get-equipped-career-wise-amid-covid-19-6228782b0943">freelancing platforms</a>.</p><h3>Introduction</h3><p>There sometimes comes a need to simply complex operations, in this case failover and failback operations of SAN storage replication between sites (e.g. production and DR), for reasons such as letting operators or the less technically-confident colleagues to more easily perform the operations in case of disasters or drill tests. To achieve that, this template has been created.</p><p>Written primarily in PowerShell, this package contains a set of SAN storage failover and failback scripts for Microsoft Failover Cluster (including Hyper-V cluster) and vendor-neutral pseudo code for SAN storage (for further modification to support different SAN vendors). Not only does it perform storage failover and failback, services running on top of it such as databases and virtual machines can also be catered.</p><p>Moreover, it features a user-friendly interactive console menu, where complex operations are handled by the scripts in the backend.</p><p><strong>[Go to </strong><a href="https://tech.wandersick.com/2018/05/general-san-storage-failover-and.html#download"><strong>Download</strong></a><strong>]</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/0*1qGvhQM1XZk25ubA" /></figure><p>Served as a general template for implementation, one has to fill in the blanks — SAN-vendor-specific commands — to fit for his/her own use. Although the Failover Cluster parts and the interactive console menu are already there, further coding and testing cannot be avoided.</p><p>The scripts were designed to be as reusable (e.g. parameterized) as possible, in order to allow me to more easily adapt it to fit different projects. It has also been released as an open-source project on the GitHub repository <a href="https://github.com/wandersick/ws-storage-failover">ws-storage-failover</a> which encourages IT pros to fork it to for their own SAN storage systems, and if possible, contribute their modified bits in returns, assisting others who might want to implement it for their own choice of SAN storage systems.</p><h3>Features</h3><ul><li>Script failover and failback between replicated SAN storage with Microsoft Failover Cluster (Hyper-V and others)</li><li>Operator-friendly interactive console menus through which failover, failback and validation, status reporting can be performed</li><li>Steps can be performed individually or all at once</li><li>Scripted in PowerShell (Windows operations) and pseudo code (SAN-specific operations) as a template to be modified or customized</li><li>Define variables or fill in parameters in SAN-Parameters.xml and SAN-Parameters.ps1</li><li>Pseudo code of SAN operations is provided inside &lt;# #&gt; inline comment blocks to be replaced as required per command-line reference of SAN storage</li><li>Speed up development of automated/manual SAN failover/failback with this set of scripts</li><li>Leverage the command-line interface usually provided by SAN storage systems over SSH which makes it possible to use plink.exe (from PuTTY) to command SAN storage systems in scripts</li><li>Default scenario is for storage systems located in two sites with SAN-level replication</li><li>Console outputs are logged under Logs folder, with error messages separately stored</li><li>Open-source project on GitHub, encouraging forking</li></ul><h3>Requirements</h3><ul><li>SAN storage systems with SAN replication enabled (2 sites — production and DR sites assumed) with hosts running Failover Cluster (e.g. Hyper-V) in each site</li><li>A Windows client that runs the console menu with PowerShell 3.0 or above (comes with Windows 8.1 and Windows Server 2012 R2)</li><li><a href="https://drive.google.com/file/d/14-Iv8byPYI9dq6dQVg3UOBJEVy0tgC3X/view?usp=sharing">PuTTY</a> should be installed under a location specified in SAN-Parameters.ps1</li><li>A one-time authentication may be required by connecting to SAN storage systems in both sites via SSH (with PuTTY or plink.exe) in order to cache the host key in registry</li><li>Run PowerShell as Administrator prior to running the Console Menu script</li></ul><h3>Script File Structure</h3><pre>¦   SAN-Console_Menu.ps1 // Menu for selecting among operations (failover, failback, validation, etc.)<br>¦<br>+---Logs // Console output and errors are recorded separately here<br>¦       ...<br>¦<br>+---Parameters<br>¦       SAN-Parameters.ps1 // Script options can be specified here (PowerShell)<br>¦       SAN-Parameters.xml // SAN replication options specified here (XML)<br>¦<br>+---Scripts<br>        SAN-Failback.ps1 // Failback operation subscript called by Console Menu script<br>        SAN-Failover.ps1 // Failover operation subscript called by Console Menu script<br>        SAN-GetStatus.ps1 // Status querying subscript called by Console Menu script<br>        SAN-Plink.ps1 // Functions which command SAN using plink.exe from PuTTY<br>        SAN-Variables.ps1 // Variables from XML, PS1 parameter files and SAN are further processed here<br>        SAN-Validate.ps1 // Validation subscript called by Console Menu script to confirm settings are valid</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/0*-Vc8hbPklX-kOqH2" /></figure><h3>Getting Started</h3><ol><li>Edit SAN-Parameters.ps1 and .xml files for options such as changing the user account for SSH communication with your SAN.</li><li>All pseudo code (SAN-specific operations) inside &lt;# #&gt; should be replaced with the implementation of your SAN vendor. For example, change <em>Echo &lt;# display LUN #&gt;</em> to the actual command <em>lsvdisk</em> (IBM/Lenovo Storwize), <em>lun show</em>(NetApp), <em>volcoll</em> (HPE Nimble), etc.</li><li>Perform further development or customization according to your needs. For example:</li></ol><ul><li>Follow the comments in the script</li><li>Names of functions, variables and echo messages are self-explanatory</li></ul><h3>Core Functions</h3><h4>A. Failover from Site 1 to Site 2 (e.g. Production to DR)</h4><p><strong>1. Hyper-V Cluster</strong></p><ol><li>End Replication — from Production Site to DR Site</li><li>Create Clone from Replicated LUN in DR Site</li><li>Present Cloned LUN to DR Site Host, Take Disk Online, Run Replication from Production Site to DR Site</li><li>Import VM in DR Site</li><li>Disconnect VM Network Adapter in DR Site</li></ol><p><strong>2. General Failover Cluster</strong></p><ol><li>End Replication — from Production Site to DR Site</li><li>Create Clone from Replicated LUN in DR Site</li><li>Present Cloned LUN to DR Site Host, Take Disk Online, Run Replication from Production Site to DR Site</li></ol><h4>B. Failback from Site 2 to Site 1 (e.g. DR to Production)</h4><p><strong>1. Hyper-V Cluster</strong></p><ol><li>Stop and Delete Replication Group — from Production Site to DR Site</li><li>Stop and Delete Replication Group — from DR Site to Production Site</li><li>Stop VM in Production Site</li><li>Stop CSV in Production Site</li><li>Delete VM in Production Site</li><li>Unpresent LUN of CSV from Production Site Hosts</li><li>Delete LUN of CSV in Production Site</li><li>Create LUN of CSV in Production Site</li><li>Create Replication Group — from DR Site to Production Site</li><li>Add LUN to Replication Group — from DR Site to Production Site</li><li>Run Replication Group — from DR Site to Production Site</li><li>Stop VM in DR Site</li><li>Take Disk Offline in DR Site Host</li><li>Unpresent Cloned LUN from DR Site Host</li><li>Stop and Delete Replication Group — from DR Site to Production Site</li><li>Present LUN of Replicated CSV to Production Site Hosts</li><li>Run CSV in Production Site</li><li>Import VM in Production Site</li><li>Disconnect VM Network Adapters in Production Site</li><li>Run VM in Production Site</li><li>Create Replication Group — from Production Site to DR Site</li><li>Add LUN to Replication Group — from Production Site to DR Site</li><li>Run Replication Group — from Production Site to DR Site</li></ol><p><strong>2. General Failover Cluster</strong></p><ol><li>Stop and Delete Replication Group — from Production Site to DR Site</li><li>Stop and Delete Replication Group — from DR Site to Production Site</li><li>Stop CSV in Production Site</li><li>Unpresent LUN of CSV from Production Site Hosts</li><li>Delete LUN of CSV in Production Site</li><li>Create LUN of CSV in Production Site</li><li>Create Replication Group — from DR Site to Production Site</li><li>Add LUN to Replication Group — from DR Site to Production Site</li><li>Run Replication Group — from DR Site to Production Site</li><li>Take Disk Offline in DR Site Host</li><li>Unpresent Cloned LUN from DR Site Host</li><li>Stop and Delete Replication Group — from DR Site to Production Site</li><li>Present LUN of Replicated CSV to Production Site Hosts</li><li>Run CSV in Production Site</li><li>Create Replication Group — from Production Site to DR Site</li><li>Add LUN to Replication Group — from Production Site to DR Site</li><li>Run Replication Group — from Production Site to DR Site</li></ol><h3>Limitations</h3><ul><li>There is no one-size-fits-all solution — modification is inevitable</li><li>Not all error messages are separately recorded in error log file; some errors only exist in the main log. Outputs and errors encountered in the menu are not logged</li><li>SAN storage credentials are stored in the ps1 configuration file in clear text (protect the file properly)</li></ul><h3>Download</h3><p>To download the latest version of ws-storage-failover, visit its <a href="https://tech.wandersick.com/2018/05/general-san-storage-failover-and.html#download">homepage</a>.</p><h3>Release History</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*2X0e_pjkMcZ35N6AtIFYbQ.png" /></figure><p>Hope this article or the tool is useful to you. 😊</p><p><em>Originally published at </em><a href="https://tech.wandersick.com/2018/05/general-san-storage-failover-and.html"><em>https://tech.wandersick.com</em></a><em> </em>on May 30, 2018.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13d42cc6f6db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wandersick/san-storage-failover-and-failback-powershell-scripts-for-failover-cluster-e-g-13d42cc6f6db">SAN Storage Failover and Failback PowerShell Scripts for Failover Cluster</a> was originally published in <a href="https://medium.com/wandersick">a wandersick’s Tech Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>