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.

6

Related questions 29 Capture EXE output in PowerShell 2 Ouput redirection/capturing issue with Powershell and Try-Catch and external EXE 3 Powershell script: Can't read return value of executed program Related questions 29 Capture EXE output in PowerShell 2 Ouput redirection/capturing issue with Powershell and Try-Catch and external EXE 3 Powershell script: Can't read return value of executed program 0 Windows cmd.exe output in PowerShell 3 Powershell : How to capture powershell output 28 How to pipe all output of .exe execution in Powershell? 0 Failing to redirect stdout or stderr of an executable in windows 5 Powershell executable isn't outputting to STDOUT 1 Issue with running EXE from PowerShell 1 Running .exe to get String output is not saving to string variable Load 7 more related questions Show fewer related questions

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.