I haven't found a decent way to get a Windows instance in Azure started up using the azure_rm_virtualmachine module with remote PowerShell enabled from first boot.

What is the typical approach to get started with Azure Windows instances provisioned with Ansible ready to run PowerShell remote commands?

There's another Ansible module called simply azure, but appears to be deprecated by azure_rm_virtualmachine.

  • Do you mean you want to get VM status by using PowerShell. If yes, you could use Azure PowerShell. (Get-AzureRmVM -ResourceGroupName $ResourceGroup -Name $RmVM -Status).Statuses.Code[1] May 18, 2017 at 1:37
  • I mean using ansible to provision a host that has remote power shell enabled from first boot to be usable by ansible. I'll clarify the question
    – barrymac
    May 18, 2017 at 16:07

1 Answer 1


After creating the VM, use azure_rm_deployment module to create a deployment for a Custom Script Extension.

In the template specify:

  "publisher": "Microsoft.Compute",
  "type": "CustomScriptExtension",
  "typeHandlerVersion": "1.4",
  "settings": {
    "fileUris": [
    "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File ConfigureRemotingForAnsible.ps1"

Then run a play against the VM.

  • Much appreciated @techraf , thanks also for question edits!
    – barrymac
    Jun 4, 2017 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.