Forum Discussion

mcresIT's avatar
mcresIT
Copper Contributor
Jan 15, 2024
Solved

I can install a program remotely via PSEXec but can't do it via PowerShell

I'm trying to run this to install a program remotely, but nothing happens...   Invoke-Command -ComputerName $pc -ArgumentList $pc -ScriptBlock { Start-Process -FilePath "c:\windows\temp\PhishAlertB...
  • LainRobertson's avatar
    LainRobertson
    Jan 15, 2024

    mcresIT 

     

    Hi, Yosi.

     

    Running commands remotely is a different kettle of fish to running them locally in an interactive session.

     

    If you're getting no error at all then it sounds like the remote PowerShell session is establishing just fine and something is going wrong with the execution of the remote command.

     

    I'd recommend using the -Wait parameter in Start-Process, as it's reasonably common that the initial setup stub exits early, well before the installation routine has done its job. Using -Wait tells Start-Process to wait for the stub and all child processes it launched to exit before returning control to the remote calling computer.

     

    Example

    Invoke-Command -ComputerName $pc -ScriptBlock { Start-Process -Wait -FilePath "c:\windows\temp\PhishAlertButtonSetup.exe"  '/q /ComponentArgs "KnowBe4 Phish Alert Button":"LICENSEKEY=""XYZ12345""" /Log /LogFile c:\Dell\Phisher.log' }

     

     

    You can leave out the -ArgumentList parameter from Invoke-Command since you're not using it in the remote command.

     

    Cheers,

    Lain

Resources