在远程 Windows 计算机上通过 MacOS Visual Studio Code 运行 PowerShell 脚本会抛出 MI_RESULT_FAILED。

6

我试图在MacOS(Monterey M1)通过Visual Studio Code运行和调试一个适用于远程Windows PC的PowerShell脚本。

Mac

Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Darwin 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.6…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

个人计算机
 Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}       
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

在 Mac 上,我已经安装了 PSWSMan 并按照这篇文章 https://petri.com/how-to-run-code-remotely-in-visual-studio-code 的指引尝试使用以下命令来启动远程会话:

Enter-PSSession -ComputerName '192.168.1.185' -Credential xxx

系统在密码输入后立即抛出此错误:
Enter-PSSession: Connecting to remote server 192.168.1.185 failed with the following error message : MI_RESULT_FAILED For more information, see the about_Remote_Troubleshooting Help topic.

这可能是由于NTLM不兼容引起的:https://github.com/dotnet/runtime/issues/887 有人成功地运行了这个方案吗?

您有没有可能解决这个问题。我在MacOS上使用PS 7.3.3也遇到了完全相同的问题。 - EmmaRenee19
不,我已经放弃了这个.... 好奇想知道你是否能找出来。 - Riccardo
1个回答

0
为了解决MI_RESULT_FAILED问题,请尝试使用完整的UPN凭据。
我们的系统在一个域上(我的基于M1芯片的Mac不在该域上)。我们的企业内部AD域格式如下:DOMAIN.LOCAL(与domain.com或我们用于电子邮件和Azure登录的备用域emaildomain.com不同)。我能够成功远程连接到名为MYPC01的基于Windows的计算机,使用以下方法:
Enter-PSSession -ComputerName MYPC01 -Credential username@domain.local

以下是我在我的Mac上成功连接到我们的域控制器的屏幕截图:

Screenshot of successful PowerShell connection from Mac to PC

输入exit退出会话并返回到您的Mac终端上的本地PS会话。
供参考,以下是我Mac上PowerShell安装的输出:
$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Darwin 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 21:00:41 PST 2023; root:xnu-8796.101.5~3/…
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

注意:您必须已经安装了WSMan,在更新macOS上的PowerShell之后可能需要重新安装。
pwsh -Command 'Install-Module -Name PSWSMan'
sudo pwsh -Command 'Install-WSMan'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接