1

I have looked though Stack Overflow for this question and haven't been able to find it. I also searched the internet with no luck so far. The answers I have found so far do not address the difference I am seeing in the same command being run from two different locations for the same server. Maybe I am not using the correct search parameters.

My Problem:

PowerShell commands shows different output when using remote invoke-command as opposed to running the command locally. I have seen this on a couple occasions.

For this example, The server running the remote invoke command is running Windows Server 2012 with PS 4 version.

The server being tested is running Windows Server 2008 R2 with PS 2 version.

I log into both servers with the Domain Administrator login.

====
**Notice Version shows 1.0.0.0 when using remote command.

2012 v4:

(I tried piping to format table, but same result)

invoke-command -computername mail1.dcloud.cisco.com -scriptblock {Get-host} 

PSComputerName   : mail1.dcloud.cisco.com
RunspaceId       : 6ccceb7b-5fa0-42b7-b78f-22b17116f4d3
Name             : ServerRemoteHost
Version          : 1.0.0.0
InstanceId       : 28263e00-11f9-4d78-98c2-f789659b23c8
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : 

===========
** Notice version is 2.0 when run locally on server.

2008 R2 v2

PS C:\> $env:ComputerName
MAIL1

PS C:\> get-host


Name             : ConsoleHost
Version          : 2.0
InstanceId       : d4cf14b5-5925-4fb5-9307-eaf8cbcd11f5
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

12/2/17 13:25 EDT - EDIT: If I change my command to enter-pssession, I get the info that I believe to be correct.

PS C:\python> enter-pssession mail1
Get-host


Name             : Windows PowerShell ISE Host
Version          : 4.0
InstanceId       : 7e3f6039-3b63-4c8e-af49-bc748c07ed7e
UI               :System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.Host.ISE.ISEOptions
IsRunspacePushed : True
Runspace         : System.Management.Automation.RemoteRunspace


[mail1]: PS C:\Users\Administrator.DCLOUD\Documents> exit-pssession

Still have not found out why Invoke-Command gives a different output for the command Get-Host.

1 Answer 1

1

Get-Host returns the details of the current host. If you are in PowerShell console, it returns the version of the console host. If you are in a remote session it returns the version of the remote host(not the PS version in remote server).

Note: Host version and PowerShell version aren't same.

even ISE is a different host for powershell

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Prasoon Karunan for that answer. I did not know that. I will adjust my script accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.