
我正在嘗試從我的機器“A”登入 Windows 2008 伺服器“C”。在“B”之間有一台機器作為跳箱運行 Windows Server 2008 並運行“SSH-Enabled PowerShell Access for Windows (powershellserver.com)”
我正在從我的機器“A”到機器 B 進行 ssh 操作。我能夠從機器 BI 創建到機器 C 的 PSsession,但無法進入會話,以下是我看到的錯誤。
PS C:\Users\Documents> New-PsSession -Credential $mycreds -Computername x.x.x.x
Id Name ComputerName State ConfigurationName Availability
-- ---- ------------ ----- ----------------- ------------
228 Session228 x.x.x.x Opened Microsoft.PowerShell Available
PS C:\Users\Documents> Get-PSSession | Remove-PSSession
PS C:\Users\Documents> $session = New-PsSession -Credential $mycreds -Computername x.x.x.x
PS C:\Users\Documents> enter-pssession $session
enter-pssession : The method or operation is not implemented.
At line:1 char:1
+ enter-pssession $session
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:) [Enter-PSSession], PSNotImplementedException
+ FullyQualifiedErrorId : NotImplemented,Microsoft.PowerShell.Commands.EnterPSSessionCommand
當我使用 RDP 登入電腦 B,然後在電腦 C 上進行會話時,它工作正常。那麼為什麼它不能在 ssh 會話中工作呢?
如果需要進一步說明,請告訴我。
先致謝!
答案1
你必須使用下面的命令
$s = New-PSSession -ComputerName Server02 -Credential Domain01\User01
Invoke-Command -Session $s -ScriptBlock {commands....}