Invoke-Command 出現奇怪錯誤:此平台不支援 Windows 主要功能

Invoke-Command 出現奇怪錯誤:此平台不支援 Windows 主要功能

有時,當我嘗試從 Linux 中的 PowerShell 在 PowerShell 會話中執行遠端命令時,會收到以下錯誤:

Invoke-Command:此平台不支援 Windows 主要功能。

在 Mac 中使用 PowerShell 可以正常運作,但在 Linux 中使用 PowerShell 則不行。

從 Ubuntu 中:

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.1
PSEdition                      Core
GitCommitId                    v6.0.1
OS                             Linux 4.4.0-1041-aws #50-Ubuntu SMP Wed Nov 15 22:18:17 UTC 2017
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

來自 CentOS:

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.2
PSEdition                      Core
GitCommitId                    v6.0.2
OS                             Linux 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

如果我嘗試使用 Enter-PSSession 我總是得到:

Enter-PSSession :您目前位於 PowerShell PSSession 中,無法使用 Enter-PSSession cmdlet 進入另一個 PSSession。

然後,Invoke-Command 就可以正常運作了。

Invoke-Command 在從 Enter-PSSession 收到錯誤後起作用

相關內容