# host vs remote invoke-command

**URL:** <https://forums.powershell.org/t/host-vs-remote-invoke-command/2641>\
**Category:** PowerShell Help\
**Created:** [June 2, 2014, 6:20am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641 "2014-06-02T06:20:28Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![nghia-tran](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/nghia-tran/32/871_2.png) [@nghia-tran](https://forums.powershell.org/u/nghia-tran)\
**Post date:** [June 2, 2014, 6:20am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/1 "2014-06-02T06:20:28Z")

</div>

Hi all,  
Would anyone know why I’m able to execute this command directly on my remote hyper-v vm:  
`Start-Process C:\Folder\SomeProgram.exe -ArgumentList /s -Wait`

But this fails when I do this on the host machine:

```auto
$session = New-Pssession -ComputerName pc1 -Credential pass1
Invoke-Command -Session $session -ScriptBlock {Start-Process C:\Folder\SomeProgram.exe -ArgumentList /s -Wait}

```

Host PC OS: windows server 2012 datacenter  
Remote PC OS: windows 7 (running PSv2)

Please let me know if you need any other information.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![mikefrobbins](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/mikefrobbins/32/272_2.png) [@mikefrobbins](https://forums.powershell.org/u/mikefrobbins)\
**Post date:** [June 2, 2014, 9:38am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/2 "2014-06-02T09:38:34Z")

</div>

The -Credential parameter needs a credential object, not just a password.

`
$session = New-Pssession -ComputerName pc1 -Credential (Get-Credential)
`

Verify PowerShell remoting is enabled on the Windows 7 computer named pc1 (it’s not enabled by default). Run Enable-PSRemoting on pc1.

---

<div class="post-metadata">

**Author:** ![nghia-tran](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/nghia-tran/32/871_2.png) [@nghia-tran](https://forums.powershell.org/u/nghia-tran)\
**Post date:** [June 2, 2014, 9:46am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/3 "2014-06-02T09:46:44Z")

</div>

Thank you for the reply, but I’ve already double checked those two variables:  
I was able to do this on my host, which verifies that i can communicate to my pc1.  
`Enter-PSSession -ComputerName pc1 -Credential <userName> `

i miss-typed my credential from above. I manually enter in my password for now, until i can get a running version.

---

<div class="post-metadata">

**Author:** ![nghia-tran](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/nghia-tran/32/871_2.png) [@nghia-tran](https://forums.powershell.org/u/nghia-tran)\
**Post date:** [June 2, 2014, 9:47am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/4 "2014-06-02T09:47:34Z")

</div>

I’m also using the admin account for both the host and the hyper-v vm…

---

<div class="post-metadata">

**Author:** ![mikefrobbins](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/mikefrobbins/32/272_2.png) [@mikefrobbins](https://forums.powershell.org/u/mikefrobbins)\
**Post date:** [June 2, 2014, 9:57am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/5 "2014-06-02T09:57:01Z")

</div>

For simplicity, give this a try:

Create the $session as you previous were, then try this:

`
Invoke-Command -Session $session {Start-Process Notepad.exe}
`

Then check to make sure notepad is running:

`
Invoke-Command -Session $session {Get-Process Notepad}
`

---

<div class="post-metadata">

**Author:** ![nghia-tran](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/nghia-tran/32/871_2.png) [@nghia-tran](https://forums.powershell.org/u/nghia-tran)\
**Post date:** [June 2, 2014, 10:04am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/6 "2014-06-02T10:04:40Z")

</div>

Yes, that gave me a result with the “ProcessName” of notepad

Now I’m really lost. Not sure where the disconnect.

---

<div class="post-metadata">

**Author:** ![mikefrobbins](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/mikefrobbins/32/272_2.png) [@mikefrobbins](https://forums.powershell.org/u/mikefrobbins)\
**Post date:** [June 2, 2014, 10:08am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/7 "2014-06-02T10:08:28Z")

</div>

Can you run the same type of test for the process you’re attempting to run?

`
Invoke-Command -Session $session -ScriptBlock {Start-Process C:\Folder\SomeProgram.exe -ArgumentList /s -Wait}
``
Invoke-Command -Session $session -ScriptBlock {Get-Process SomeProgram}
`

Note: SomeProgram should be running on the remote machine, but it will not be running interactively in the console.

---

<div class="post-metadata">

**Author:** ![nghia-tran](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/nghia-tran/32/871_2.png) [@nghia-tran](https://forums.powershell.org/u/nghia-tran)\
**Post date:** [June 2, 2014, 10:16am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/8 "2014-06-02T10:16:51Z")

</div>

Yes, this returned a result:

`Invoke-Command -Session $session -ScriptBlock {Get-Process SomeProgram}`

i also see the process running in the IP Address I wanted it to be on. I went a step further and looked at the event log on the VM:

getting this error: “The description for Event ID 0 from source .NET Runtime cannont be found.”

At least I’m moving forward, I did not get this error when I run the Start-Process directly on the VM… I will have to look up what that error is all about and how it’s related to Powershell, if any.

---

<div class="post-metadata">

**Author:** ![mikefrobbins](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/mikefrobbins/32/272_2.png) [@mikefrobbins](https://forums.powershell.org/u/mikefrobbins)\
**Post date:** [June 2, 2014, 10:21am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/9 "2014-06-02T10:21:00Z")

</div>

Is the same user account being used to start the process locally and remotely?

---

<div class="post-metadata">

**Author:** ![nghia-tran](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/nghia-tran/32/871_2.png) [@nghia-tran](https://forums.powershell.org/u/nghia-tran)\
**Post date:** [June 2, 2014, 10:21am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/10 "2014-06-02T10:21:43Z")

</div>

Yes, the same user account (with admin rights) is being used.

---

<div class="post-metadata">

**Author:** ![nghia-tran](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/nghia-tran/32/871_2.png) [@nghia-tran](https://forums.powershell.org/u/nghia-tran)\
**Post date:** [June 2, 2014, 10:43am UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/11 "2014-06-02T10:43:17Z")

</div>

Just so I know I’m not going crazy, I went and reran the code below on my VM directly and it works the way it supposes to.  
`Start-Process C:\Folder\SomeProgram.exe -ArgumentList /s -Wait</code>`

`
Not sure where the disconnect is when I use the invoke-command
Could this be a UAC issue? I’m trying doing a silent install of my .exe – from what i can tell of my run without the invoke-command the /s should have taken care of any UI and the admin right should take care of an UAC issues that i might encounter… Am I wrong?`

---

<div class="post-metadata">

**Author:** ![peter-jurgens](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@peter-jurgens](https://forums.powershell.org/u/peter-jurgens)\
**Post date:** [June 2, 2014, 8:15pm UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/12 "2014-06-02T20:15:09Z")

</div>

You may be right about UAC. Only local administrator is never prompted for elevation by UAC, so even if the user account that you are using to start the application is an admin on the machine, by default the computer would still prompt for elevation.

When you run this code on the VM directly (as you said), does it prompt for elevation?

```
Start-Process C:\Folder\SomeProgram.exe -ArgumentList /s -Wait
```

If so, I’d say you have 3 options,

1. Look into how to change UAC settings so it automatically elevates without prompting.
2. Try starting the process with the local administrator credentials for the machine.
3. Examine your installer further. I know a lot of exe installers are just wrappers for an MSI, and if so you may be able to extract the contents of the installer, retrieve the MSI and install using MSIEXEC, which plays much nicer with UAC.

---

<div class="post-metadata">

**Author:** ![nghia-tran](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/nghia-tran/32/871_2.png) [@nghia-tran](https://forums.powershell.org/u/nghia-tran)\
**Post date:** [June 2, 2014, 11:25pm UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/13 "2014-06-02T23:25:44Z")

</div>

Hi Peter,  
Thank you for your input. I was able to run `Start-Process C:\Folder\SomeProgram.exe -ArgumentList /s -Wait` directly without any prompts and everything installs just as I expected. My issue is with the Invoke-Command.

I will give option 3 a try: My installer has a SQL Express 2012 and an .msi in it… at this point I’m willing to try anything 🙂

---

<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:52pm UTC](https://forums.powershell.org/t/host-vs-remote-invoke-command/2641/14 "2024-05-16T20:52:01Z")

</div>

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


