Back in June of this year I presented a session at PowerShell Southampton on using Ansible and PowerShell together. There was a fair amount of interest in this topic both at the event and online afterwards, so I decided to follow it up here with a series of posts looking at the basics for someone getting started with Ansible. In particular using it to automate and configure Windows, where to use PowerShell for that task and sometimes where not to if there is native functionality already available within Ansible.
As part of a large configuration script for Windows, and executed via Ansible, one step was to remove SMB1. The official Microsoft Guidance on removing SMB1 states to use Disable-WindowsFeature - https://support.microsoft.com/en-gb/help/2696547/detect-enable-disable-smbv1-smbv2-smbv3-in-windows-and-windows-server I didn’t think too much more of this and simply added the step to the configuration script. However, upon executing it from Ansible I received the following error: This got me questioning why is the recommendation to use Disable-WindowsOptionalFeature when the detect method is Get-WindowsFeature?
While working on a scenario where I needed to automate the installation of SCVMM 2019, firstly via PowerShell scripts and then those scripts plugged into an Ansible playbook, I encountered some failures during the Ansible execution of the PowerShell scripts. These same scripts had worked fine when run locally on the Windows 2016 Server designated to run SCVMM. The PowerShell scripts automated the install of three components; SQL, ADK and SCVMM.