Jump to content
holytoutant

ShellResult returns OK

Recommended Posts

Posted (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.

 

LTClient_Q0H6sUqhR1.png

LTClient_6RXQ1YNdP9.png

Edited by holytoutant

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Posted (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 by BlueToast

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...