-Wait not woking with invoke-command

Good morning,

I am trying to install a driver on a remote system with powershell. If I run the command locally it works fine and installs the driver.

Start-Process -FilePath "C:\Audio_Driver_T82DN_WN_1.0.54.0_A05.EXE" -ArgumentList ('/q')  -Wait -NoNewWindow

But once I wrapped with an Invoke-command it no longer works.

Invoke-Command -ComputerName $ComputerName -Credential (Get-Credential) -ScriptBlock { Start-Process -FilePath "C:\Audio_Driver_T82DN_WN_1.0.54.0_A05.EXE" -ArgumentList ('/q') -PassThru -Wait -NoNewWindow }

The cursor returns after only a few seconds and the driver does not install. I tired adding in a -credential (get-credential) and while it does ask for my credentials it still fails.
here is the full script with company and pc info removed.

function Install-Make_Model_Audio_Driver{
[CmdletBinding()]
param(
    [Parameter(Mandatory=$True)]
    [string[]]$ComputerName
)

Copy-Item -Path '\\PathToDriver\Audio_Driver_T82DN_WN_1.0.54.0_A05.EXE' -Destination "\\$ComputerName\C$\Audio_Driver_T82DN_WN_1.0.54.0_A05.EXE" -Verbose

Invoke-Command -ComputerName $ComputerName -Credential (Get-Credential) -ScriptBlock { Start-Process -FilePath "C:\Audio_Driver_T82DN_WN_1.0.54.0_A05.EXE" -ArgumentList ('/q') -PassThru -Wait -NoNewWindow }

Remove-Item -Path "\\$ComputerName\C$\Audio_Driver_T82DN_WN_1.0.54.0_A05.EXE"
}

Caveat, Our envoirment is completely locked down with numbers VLANS which requires me use invoke-command to run commands locally on systems as we will not allow all TCP needed.

I would appreciate any help this.
Thank you

Add -Wait to your start process. Once the remote commands are sent and the session is exited, all child processes on the remote host are exited. The -Wait should take care of it

Krzydoug, I do have a -Wait in start-process. it works locally but not remotely with invoke-command

Sorry I didn’t see that.

Random thoughts:

I would try it without -NoNewWindow.
And it doesn’t seem like -PassThru is needed?

Darwin,

Thank you for the suggestion. I belive I had already tried remobing –NoNewWindow but I tried it again. Still the same. The exe starts but then closes a second later. I like to use –PassThru so that I can see that the process starts to run when I use invoke-command.

To work around the issue I created a cmd file with C:\name.exe /s then copied that to file to C:\ and then used invoke-command to run it with -ArgumentList (“/q”) -PassThru -Wait -NoNewWindow

That worked fine.

So for some reason the –wait is not working inside a invoke-command