Invoke-command to run msi remotely not working

This topic contains 7 replies, has 3 voices, and was last updated by  Stefan Werner 2 years, 1 month ago.

  • Author
  • #38692

    bvi1998 .

    If I run the command below on the machine itself, it works.
    invoke-command -scriptblock {"Start-Process -FilePath '$env:systemroot\system32\msiexec.exe' -ArgumentList '/i c:\util\nagios\NSCP- /qn /norestart' -Wait -WorkingDirectory c:\util\nagios"}

    if I run it on a remote computer, it seems to do nothing.
    invoke-command -credential $cred -computername $server -scriptblock {"Start-Process -FilePath '$env:systemroot\system32\msiexec.exe' -ArgumentList '/i c:\util\nagios\NSCP- /qn /norestart' -Wait -WorkingDirectory c:\util\nagios"}

    Can someone give me an idea as to why this is happening?

  • #38697

    Stefan Werner

    Have you given PsExec a go?

    $cmd = 'cmd.exe /c msiexec.exe /i c:\util\nagios\NSCP- /qn /norestart'
    .\psexec.exe \\client -h -accepteula -s $cmd
  • #38698

    bvi1998 .

    Hi, Yes, I struggled a ton with that one, I finally gave up.
    I am using the same command for a different msi, so I don't know what is different about this one. I can install it with the invoke-command locally... I think it will have something to do with permissions, but I can't figure out what. I need to be running it as administrator of course...

  • #38736

    Yuan Li

    Hey mate,

    I think you should escalate the permission when you run remotely.
    for example

     nvoke-command -credential $cred -computername $server -scriptblock {"Start-Process -FilePath '$env:systemroot\system32\msiexec.exe' -ArgumentList '/i c:\util\nagios\NSCP- /qn /norestart' -verb runas -passthrough -Wait -WorkingDirectory c:\util\nagios"}
  • #38750

    Stefan Werner

    By what I have experienced, some packages don't like to be installed remotely. This is where PsExec's ability to run as Local System comes in handy.

    Are you getting any errors back from your invoke command?

  • #38752

    bvi1998 .

    @Yuan, this does not work for me either. No error messages.
    @Stefan, yes I have the msi stored locally on the server and I still cannot execute it. Basically the msiexec under the system account just sits there in task manager....
    Thanks All.

  • #38767

    bvi1998 .

    This is what my batch file looks like:
    c:\util\nagios\NSCP- /qn
    timeout /t 30
    net stop nsclientpp
    net stop nscp
    xcopy c:\util\nagios\*.ini C:\"Program Files"\NSClient++\*.* /s /Y
    del C:\"Program Files"\NSClient++\nsc.ini

    I run it like this:
    & C:\scripts\PsExec.exe -accepteula \\$server -u "$username" -p "$password" -s -d -h "c:\util\nagios\install.cmd"

    I found the only way to make it all work together was to first execute the msi with psexec. Then I run the next set of commands with another psexec to stop the service(might be an old service or new, that's why there are 2 net stops)

    Not sure what the problem is, but at least it works, though not very efficient 🙂

  • #38782

    Stefan Werner

    Glad you got it working. Would it help to stop the services before hand? We don't use Nagios here, so it is hard for me to say where the hangup is coming from.

You must be logged in to reply to this topic.