Estou tentando conectar-me a um computador remoto usando uma sessão local do PowerShell.
para isso, estou tentando usar os comandos Enter-PSSession ou New-PSSession do PowerShell local como:
$session = New-PSSession -ConnectionUri 'http://testserverUri.dom/PowerShell'
Mas estou recebendo todas as vezes após exceção.
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
Também usei outra variação:
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
Na maioria dos casos, estou recebendo a primeira exceção.
Essa mesma exceção está ocorrendo enquanto estou abrindo o espaço de execução usando C# e fornecendo o objeto WSManConnectionInfo com o url powerSell do servidor remoto.
Eu já fiz tudo em relação aos comandos winrm, mas isso realmente não resolve o problema. Como se livrar desse problema?
Responder1
Por que não simplesmente Enter-PSSession apdv0710.forest7.dom
?
Você precisa executar Enable-PSRemoting
apdv0710.forest7.dom primeiro.
Responder2
Isso funcionou para mim, fornecendo apenas o nome do computador, Kerberos como mecanismo de autenticação, além do objeto de credencial contendo nome de usuário e senha.
New-PSSession -Authentication Kerberos -Computer 'apdv004s' -Cred $credential
Mesmo uso para Enter-PSSession
.