Я пытаюсь подключиться к удаленному компьютеру с помощью локального сеанса PowerShell.
для этого я пытаюсь использовать локальные командлеты PowerShell Enter-PSSession или New-PSSession как:
$session = New-PSSession -ConnectionUri 'http://testserverUri.dom/PowerShell'
Но я получаю все время следующее исключение.
New-PSSession : [testserveruri.dom] Connecting to remote server apdv0710.forest7.dom failed with the following
error message : The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was
not available. This is usually returned by a HTTP server that does not support the WS-Management protocol. For more
information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $session = New-PSSession -ConnectionUri 'http://testserverUri.dom/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
gTransportException
+ FullyQualifiedErrorId : URLNotAvailable,PSSessionOpenFailed
Я также использовал другой вариант:
Enter-PSSession -Authentication Kerberos -ConnectionUri 'http://testserveruri.dom/PowerShell' -Cred $credential
Enter-PSSession : Connecting to remote server apdv0710.forest7.dom failed with the following error message : The WinRM
client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is
usually returned by a HTTP server that does not support the WS-Management protocol. For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $session = Enter-PSSession -Authentication Kerberos -ConnectionUri 'h ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (http://testserveruri.dom/PowerShell:Uri) [Enter-PSSession], PSRemot
ingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
В большинстве случаев я получаю первое исключение.
Это же исключение возникает, когда я открываю пространство выполнения с помощью C# и предоставляю объекту WSManConnectionInfo URL-адрес удаленного сервера powerSell.
Я уже все обошел вокруг относительно команд winrm, но это не решает проблему. Как избавиться от этой проблемы?
решение1
Почему бы просто не Enter-PSSession apdv0710.forest7.dom
?
Сначала вам нужно запустить Enable-PSRemoting
apdv0710.forest7.dom.
решение2
Это сработало для меня, поскольку было указано только имя компьютера, Kerberos в качестве механизма аутентификации, а также объект учетных данных, содержащий имя пользователя и пароль.
New-PSSession -Authentication Kerberos -Computer 'apdv004s' -Cred $credential
То же самое использование для Enter-PSSession
.