1

I am working on developing post-deployment Pester validation script for my project. I need to push pester scripts into the VM as custom script extension using Azure CLI.

Following is the command I executed:

az vm extension set --resource-group SomeRG--vm-name SimpleVM --name 
customScript --publisher Microsoft.Azure.Extensions --settings '{"fileUris": 
["https://github.com/myname/DSCConfig/blob/master/pester.ps1"], 
"commandToExecute":"powershell -ExecutionPolicy Unrestricted -File 
pester.ps1"}'  --version 2.0

and I got the below error in the Linux interface after executing above command:

Deployment failed. Correlation ID: 8ba16fc0-fea6-4650-bb0a-2b73c9613dfe. Handler 'Microsoft.Azure.Extensions.customScript' has reported failure for VM Extension 'customScript' with terminal error code '1007' and error message: 'Install failed for the plugin (name: Microsoft.Azure.Extensions.customScript, version 2.0.6) with exception The specified executable is not a valid application for this OS platform.'

And while checking the extension on VM saw the status as "Transitioning " and details as Install failed for the plugin (name: Microsoft.Azure.Extensions.customScript, version 2.0.6) with exception The specified executable is not a valid application for this OS platform)

Alternatively I tried with other publishers: Microsoft.Compute and Microsoft.OSTCExtensions

Unfortunately, none of them worked. I have been stuck at this step for past two days. Any help is much appreciated.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
Melbin K
  • 55
  • 1
  • 2
  • 6
  • The error seems to suggest that your target VM is not a Windows machine, but rather some other OS where Windows PowerShell is not supported. If this is the case there is now PowerShell Core that is cross-platform but I don't personally know if you can use it via custom script extensions yet. – Mark Wragg Jul 18 '18 at 08:26
  • Thanks for your input Mark. But the VM I am trying to access is a simple VM configured on windows OS. I have used Microsoft.Azure.Extensions which is throwing the error " 'Install failed for the plugin (name: Microsoft.Azure.Extensions.customScript, version 2.0.6) with exception The specified executable is not a valid application for this OS platform.'" – Melbin K Jul 19 '18 at 08:59

1 Answers1

2

I think you might be using the wrong custom script extension (the one you are using I believe is for Linux VMs). I think you should be using the one named "CustomScriptExtension" with a publisher of "Microsoft.Compute" and version set to "1.9" as documented here.

Specifically, try this command instead:

az vm extension set --resource-group SomeRG--vm-name SimpleVM --name CustomScriptExtension --publisher Microsoft.Compute --settings '{"fileUris": ["https://github.com/myname/DSCConfig/blob/master/pester.ps1"], "commandToExecute":"powershell -ExecutionPolicy Unrestricted -File pester.ps1"}' --version 1.9
Mark Wragg
  • 22,105
  • 7
  • 39
  • 68
  • Awesome, I got the fix for the error now. As you rightly mentioned I tried publisher as micosoft.compute with name as CustomScriptExtension and it worked like a charm. Thankslot. – Melbin K Jul 20 '18 at 08:04