holytoutant 0 Posted July 28, 2020 Share Posted July 28, 2020 (edited) Hi all, I have been working with Automate Scripts for quite some time now and I have one issue which support cannot seem to understand. Everytime I use a Shell Function (Shell as Admin, Shell, Shell Enhanced), the variable %shellresult% always return OK, whether I am running an actual shell command (Like ping google.com) or if I am executing a powershell script. Do you have any idea on what could cause the issue. See one script result and content in attachement. Edited July 28, 2020 by holytoutant Quote Link to post Share on other sites
holytoutant 0 Posted July 28, 2020 Author Share Posted July 28, 2020 ATM the script's shell is: %SYSTEMROOT%\system32\cmd.exe /c %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -command %ltsvcdir%\Scripts\HyperVMaintainer3.0.ps1 But initially it was powershell.exe -executionpolicy bypass -command %ltsvcdir%\Scripts\HyperVMaintainer3.0.ps1 It was just a test I made Quote Link to post Share on other sites
BlueToast 20 Posted July 29, 2020 Share Posted July 29, 2020 (edited) Don't call cmd.exe /c within Shell unless there is a technical reason that you understand with great confidence (in the what, why, and how). Shell IS cmd.exe /c, so you are unnecessarily creating a nesting of essentially cmd.exe /c "cmd.exe /c "commandstuff"". Use this: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "& C:\Windows\LTSvc\Scripts\HyperVMaintainer3.0.ps1" Also, make sure that your HyperVMaintainer3.0.ps1 at minimum outputs some sort of text, i.e. "noData", no matter what. If a variable that is passed to Write-Host could potentially be empty or null, set the variable to at least "noData". Your PowerShell script may actually be running but outputting nothing, which would generate an "OK" response (because the output is empty, without content = CWA will default to "OK"). Edited July 29, 2020 by BlueToast Quote Link to post Share on other sites
holytoutant 0 Posted August 24, 2020 Author Share Posted August 24, 2020 Hi, Thanks for the reply. After changing to Shell and using the format you use to launch PowerShell I was able to sucessfully get the output! Regards, Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.