Recently I needed an easy function to add additional servers roles on several IaaS virtual machines on a customer platform. This is how I accomplished this.
For this example I’m going to install the IIS server role, it works for other roles ofcourse. I’ve created an simple powershell script with the following content :
Install-WindowsFeature -name Web-Server -IncludeManagementTools
For this demo I named the .ps1 file InstallIIS.ps1
Using visual studio code I’ve specified my Azure subscription and invoke the powershell command :
Set-AzureRmContext -Subscription XX-XX-4693-bcad-ca3244783864 Invoke-AzureRmVMRunCommand-CommandId "RunPowerShellScript"-ResourceGroupName "my-resource-group"-VMName "demo-vm-001"-ScriptPath "C:\PS\InstallIIS.ps1"
After executing this command the IIS role will be installed on the demo-vm-001 server.
[do_widget id=hootkit-notice-3]