masuberu
masuberu

Reputation: 117

What is wrong with my PS version?

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
  1. What is the difference between execute the command locally and remotely?

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

Answers (2)

David Jones
David Jones

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

Tim Ferrill
Tim Ferrill

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

Related Questions