Reputation: 117
The PS version of my server is version 3 or 1 depending on whether the request is done on the local shell or remotely:
I get PS version 3 on the local server
PS C:\Users\ea_admin> (Get-Host).Version
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
And I get PS version 1 on same server running (Get-Host).Version remotely:
Invoke-Command -Session $session {
return (Get-Host).Version
}
"Major": 1,
"Minor": 0,
"Build": 0,
"Revision": 0,
"MajorRevision": 0,
"MinorRevision": 0,
"PSComputerName": "remote.server1234567890.com.au",
"RunspaceId": "23634ba8-bfe3-4242-8593-bed3d9aa8ad1",
"PSShowComputerName": true
What is the difference between execute the command locally and remotely?
I have a script which I don't have access and it is giving a warning message regarding my PS version and I need to get rid of that message.
thanks
Upvotes: 2
Views: 415
Reputation: 3342
(Get-Host).Version returns the version of the host application.
(Get-Host).Runspace.Version return the version of the PowerShell operating environment.
Upvotes: 0
Reputation: 1674
Remoting uses a different host. If you just do Get-Host
you should see some other differences. You should be able to specify which version to use within the session.
Register-PSSessionConfiguration -Name PS3 -PSVersion 3.0
$s = New-PSSession -ComputerName Server01 -ConfigurationName PS3
Upvotes: 3