Author Posts

May 6, 2016 at 8:38 am

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!

May 6, 2016 at 10:47 am

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

May 6, 2016 at 11:22 am

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!

May 8, 2016 at 8:24 pm

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"}

May 9, 2016 at 5:13 am

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?

May 9, 2016 at 5:19 am

@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.

May 9, 2016 at 6:50 am

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 🙂

May 9, 2016 at 9:21 am

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.