I am trying to execute Powershell command remotely, my problem is that the Powershell is used is version 4.0, and I want to execute my command remotely using Powershell Core 6.0.4.
I tried to use this command on the remote host
Set-PSSessionConfiguration -name microsoft.powershell -psversion 6.0 -FORCE
And getting this error:
Set-PSSessionConfiguration : Cannot bind parameter 'PSVersion' to the target. Exception setting "PSVersion": "The
value 6.0 is not valid for the PSVersion parameter. The available values are 2.0,3.0 and 4.0."
I got version 6.0.4 installed on my remote machine.
I know it uses version 4 to execute my remote command, because
Invoke-Command -Session $session -ScriptBlock {$PSVersionTable.PSVersion};
returns:
Major Minor Build Revision PSComputerName
----- ----- ----- -------- --------------
4 0 -1 -1 IIS-DEV2
Any ideas how to force it to use version 6?