Invoke-command to run msi remotely not working

Tagged: 

This topic contains 7 replies, has 3 voices, and was last updated by Profile photo of Stefan Werner Stefan Werner 4 months, 3 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #38692
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    Hi,
    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-0.4.3.142-x64.msi /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-0.4.3.142-x64.msi /qn /norestart' -Wait -WorkingDirectory c:\util\nagios"}

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

    #38697
    Profile photo of Stefan Werner
    Stefan Werner
    Participant

    Have you given PsExec a go?
    https://technet.microsoft.com/en-us/sysinternals/psexec.aspx

    $cmd = 'cmd.exe /c msiexec.exe /i c:\util\nagios\NSCP-0.4.3.142-x64.msi /qn /norestart'
    .\psexec.exe \\client -h -accepteula -s $cmd
    
    #38698
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    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...
    Thanks!

    #38736
    Profile photo of Yuan Li
    Yuan Li
    Participant

    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-0.4.3.142-x64.msi /qn /norestart' -verb runas -passthrough -Wait -WorkingDirectory c:\util\nagios"}
    
    
    #38750
    Profile photo of Stefan Werner
    Stefan Werner
    Participant

    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
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    @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
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    This is what my batch file looks like:
    c:\util\nagios\NSCP-0.4.3.142-x64.msi /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
    Profile photo of Stefan Werner
    Stefan Werner
    Participant

    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.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.