I have a Win2003 running Powershell v2. If I run
Invoke-Command -ScriptBlock {$Host.Version}
then I get "Version 2.0". However, if I run
Invoke-Command -ScriptBlock {$Host.Version} -ComputerName localhost
then I get "Version 1.0"
I assume it's something to do with remote powershell but I've been unable to find the setting. Can anyone help?
NB.
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin\Microsoft.PowerShell\InitializationParameters
ParamName ParamValue
--------- ----------
PSVersion 2.0
Remoting host was first introduced in v2, so remoting host's version is 1 (ServerRemoteHost). When you run Invoke-Command
without -ComputerName
you are running command in powershell.exe directly. Try to check (and compare) $Host.Name in both commands, you should see the difference.
PowerShell version is best checked with $PSVersionTable
- in v1 it's absent, in any newer version it will tell you what version of PowerShell you are currently running.