Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Return only Error Code from VBscript via Invoke-Command

$
0
0

I have a vbscript I am running on a remote system via invoke-command.  The script runs fine but I am not able to only capture the exit code from the script but am capturing everything that I have echoed out to the script using wscript.echo.

Code snippet from PS

$script:DPproduct = Invoke-Command -ComputerName $ComputerName -ScriptBlock {c:\Windows\system32\cscript.exe "c:\wkstnctl\scripts\InstallSoftware\Install.vbs" //NoLogo}

Code snippet from vbscript

WScript.Echo "Uninstalling Software"
strTest = WshShell.Run("MsiExec.exe /X {393E4C89-67E9-43BF-AD29-94D19F7624F7} REBOOT=ReallySuppress /qn /l*v " & CHR(34) & strScriptPath & "\Uninstall.log" & CHR(34), 0, True)

WScript.Echo "Uninstall Failed"
WScript.Quit (strTest)

 

When I run the above, dpproduct returns as an array and if I include an wscript.echo strTest I get the MSI return code in the array.  Is there a way to clear the echos out of the return?  So that I can just use the wscript.quit?  Or do I just need to do something along the lines of Wscript.echo "MSI return:"&strTest


Viewing all articles
Browse latest Browse all 6937

Trending Articles