小编gwo*_*dus的帖子

在远程Powershell会话中执行交互式命令不起作用

我在需要用户交互的远程PowerShell会话中执行命令时遇到麻烦。

示例:我输入一个远程会话

Enter-PSSession -ComputerName mobius
Run Code Online (Sandbox Code Playgroud)

在此会话中,我执行一个要求输入密码的命令:

[mobius]: PS C:\Windows\system32> & 'c:\Program Files (x86)\Putty\plink.exe' merlin -l joe

joe@merlin's password:
c:\Program Files (x86)\Putty\plink.exe : Using username "plakat".
    + CategoryInfo          : NotSpecified: (Using username "plakat".:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
Run Code Online (Sandbox Code Playgroud)

最后两行以红色显示。似乎有两个问题。

问题1: plink.exe将文本“使用用户名“ plakat””写入stderr。这可能会导致错误消息。我能以某种方式抑制这种情况吗?(将stderr传递到stdout或其他东西。)

问题2:该过程在我应该输入密码的位置退出。我也可以使用其他命令来重现

[mobius]: PS C:\Windows\system32> cmd /c date
Run Code Online (Sandbox Code Playgroud)

它不允许我输入日期。如果我在本地PowerShell中运行它们,这两个命令都可以工作。在这种情况下,问题1或2均未显示。

windows powershell remote-access

5
推荐指数
1
解决办法
6554
查看次数

标签 统计

powershell ×1

remote-access ×1

windows ×1