我试图远程执行Powershell命令,我的问题是使用的Powershell版本为4.0,我希望使用Powershell Core 6.0.4远程执行我的命令。
我试图在远程主机上使用这个命令。
Set-PSSessionConfiguration -name microsoft.powershell -psversion 6.0 -FORCE并得到这个错误:
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."我在我的远程机器上安装了6.0.4版本。
我知道它使用版本4来执行我的远程命令,因为
Invoke-Command -Session $session -ScriptBlock {$PSVersionTable.PSVersion};返回:
Major Minor Build Revision PSComputerName
----- ----- ----- -------- --------------
4 0 -1 -1 IIS-DEV2有什么办法强迫它使用版本6吗?
发布于 2018-08-23 11:20:10
在powershell核心的安装文件夹中,有一个脚本文件Install-PowerShellRemoting,
在您希望会话的远程服务器中运行脚本,并在远程处理时使用以下命令:
$session = New-PSSession -ComputerName IIS-DEV2 -port 5985 -Credential $mycreds -ConfigurationName "powershell.6.0.4"它起了作用,让我和Powershell核心进行了一次对话。
https://stackoverflow.com/questions/51981370
复制相似问题