I have been trying to write a script to automate software installation (IBM Spectrum Protect) for several days but I have a problem getting the output of an exe command.
This command aims to verify that the client is able to reach and is registered on the ISP server queried.
The most incomprehensible in all this is that all its commands work as expected on my dev VM (W2016 PS: 5.1.14393.5127) but not on my test VM (W2022 PS: 5.1.20348.859).
Was there a particular modification between W2016 / W2022 that would impact the processing of exe in powershell?
I tried several approaches. First I tried to capture the output to a file then read it (Get-Content) but all the commands return an empty file (same for the third one with Transcript, the file is filled with the usual comments from Transcript but the area reserved for commands remains empty...)
1st attempt:
$arg = "UPDATEPW /node:$env:COMPUTERNAME /password:$env:COMPUTERNAME /optfile:
"$OptFile"" Start-Process "$InstallDir\baclient\dsmcutil.exe" -ArgumentList $arg -NoNewWindow -Wait -RedirectStandardOutput $OutputFile
2nd attempt:
& "$InstallDir\baclient\dsmcutil.exe" UPDATEPW /node:$env:COMPUTERNAME /password:$env:COMPUTERNAME /optfile:
"$OptFile" | Out-File $OutputFile
3rd attempt:
Start-Transcript -Path $OutputFile Start-Process "$InstallDir\baclient\dsmcutil.exe" -ArgumentList $arg -NoNewWindow -Wait Stop-Transcript
Getting nowhere, I tried an interactive mode:
Start-Process -FilePath powershell -ArgumentList "-noexit -command (.\dsmcutil.exe UPDATEPW /node:$env:COMPUTERNAME /password:$env:COMPUTERNAME)" -WorkingDirectory "$InstallDir\baclient"
This command is supposed to display in a new powershell, prompt the result of the command and then I just ask the user if the command was successful or not. Unfortunately, the command does open a new command prompt but does not execute anything in it!!!
Thank you in advance for your help !
Regards.