$cred = get-credential
Invoke-Command -ComputerName server01 -Credential $cred -ScriptBlock {
$exit = Start-Process powershell.exe -ArgumentList 'c:\temp\managescomagent.ps1 -action add -gwname autodetect -envname prod' -Wait -PassThru
$exit.exitcode }
The code outputs exit code 1 and fails to install when run remotely.
If I manually run this on server01, it works.
$exit = Start-Process powershell.exe -ArgumentList 'c:\temp\managescomagent.ps1 -action add -gwname autodetect -envname prod' -Wait -PassThru
$exit.exitcode
Also, any other command like hostname works from invoke-command
$cred = get-credentialInvoke-Command -ComputerName server01 -Credential $cred -ScriptBlock {
hostname }
What am I doing wrong?
99upgrade