【发布时间】:2020-07-01 03:32:14
【问题描述】:
我正在使用 PowerShell 扩展 2020.6.0 的 Windows 10 上运行 VS Code 1.46.1。在其他设置中,我设置了
[...]
"terminal.integrated.shell.windows": C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"powershell.enableProfileLoading": true,
[...]
在 VS 代码中。
现在,每当我使用 PowerShell 集成控制台通过以下命令建立 PS 远程会话时
Enter-PSSession -computername ABC.domain.com -Credential (Get-Credential) -Authentication CredSSP
PS Session 建立成功,但是,只要我输入第一个命令,远程会话就会循环以下错误,直到我按 CTRL + C:
The term 'C:\Users\UserOnClient\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (C:\Users\FelTie...ode_profile.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
从显示的路径中,我知道它必须来自建立远程会话的客户端。这发生在各种远程 PC 上,但在从普通 PS 或 PS ISE 建立 PS 会话时不会发生。
我可以通过设置解决问题
[...]
"powershell.enableProfileLoading": false,
[...]
但是,我依赖于在本地 PC 上加载我的个人资料。
所以我猜测问题一定与集成控制台在启动(远程会话)时加载了一些配置文件有关,所以我添加了
"terminal.integrated.shellArgs.windows": "-NoProfile",
到 VS Code 设置。
但这根本没有任何影响。
我还可以看到,在我使用“powershell.enableProfileLoading”建立远程连接后:false,当我在 VS Code 的 Settings-GUI 中勾选(启用)该设置的复选框时,错误消息在远程会话立即重新开始。
感谢任何想法为什么会发生这种情况。
最好的问候, 费利克斯
【问题讨论】:
标签: powershell visual-studio-code powershell-remoting