# Invoke-command to run msi remotely not working

**URL:** <https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389>\
**Category:** PowerShell Help\
**Created:** [May 6, 2016, 3:08am UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389 "2016-05-06T03:08:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvi1998](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bvi1998](https://forums.powershell.org/u/bvi1998)\
**Post date:** [May 6, 2016, 3:08am UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389/1 "2016-05-06T03:08:33Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [May 6, 2016, 5:17am UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389/2 "2016-05-06T05:17:08Z")

</div>

Have you given PsExec a go?  
[https://technet.microsoft.com/en-us/sysinternals/psexec.aspx](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
```

---

<div class="post-metadata">

**Author:** ![bvi1998](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bvi1998](https://forums.powershell.org/u/bvi1998)\
**Post date:** [May 6, 2016, 5:52am UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389/3 "2016-05-06T05:52:43Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![yuan-li](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yuan-li](https://forums.powershell.org/u/yuan-li)\
**Post date:** [May 8, 2016, 2:54pm UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389/4 "2016-05-08T14:54:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [May 8, 2016, 11:43pm UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389/5 "2016-05-08T23:43:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bvi1998](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bvi1998](https://forums.powershell.org/u/bvi1998)\
**Post date:** [May 8, 2016, 11:49pm UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389/6 "2016-05-08T23:49:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bvi1998](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bvi1998](https://forums.powershell.org/u/bvi1998)\
**Post date:** [May 9, 2016, 1:20am UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389/7 "2016-05-09T01:20:28Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [May 9, 2016, 3:51am UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389/8 "2016-05-09T03:51:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:41pm UTC](https://forums.powershell.org/t/invoke-command-to-run-msi-remotely-not-working/6389/9 "2024-05-16T20:41:25Z")

</div>

Closed on May 16, 2024, 8:41pm UTC


