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