mardi 3 février 2015

PowerShell script from Ruby minitest in Chef not properly executing


Vote count:

0




I am trying to write a test in Chef using Chef's minitest-handler, specifically, the assert_sh function. Here is my code (I also tried it without the "status = " but getting same results:



status = assert_sh(powershell -command "& {(Get-AzureVM -ServiceName antimalware-test -Name $env:computername | Get-AzureVMMicrosoftAntimalwareExtension).state -eq 'Enable'}")


For some reason, ruby wants to use cmd.exe to run shell commands. As far as I know there is no way to run them directly from PowerShell, which is why I have to run "powershell -command". Please let me know if there is a better way. When I run everything inside the parentheses in a cmd console, it works. When I run my test, it complains about the "&", stating that it's an unexpected character. I have tried escaping it and even removing it. When I remove it, it complains about "-ServiceName".



asked 1 min ago







PowerShell script from Ruby minitest in Chef not properly executing

Aucun commentaire:

Enregistrer un commentaire