Ich versuche, über eine lokale Powershell-Sitzung eine Verbindung zum Remotecomputer herzustellen.
dafür versuche ich, die lokalen Powershell-Commandlets „Enter-PSSession“ oder „New-PSSession“ zu verwenden, und zwar wie folgt:
$session = New-PSSession -ConnectionUri 'http://testserverUri.dom/PowerShell'
Aber ich erhalte ständig die folgende Ausnahme.
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
Ich habe auch andere Varianten verwendet:
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
In den meisten Fällen erhalte ich die erste Ausnahme.
Dieselbe Ausnahme tritt auf, wenn ich mit C# einen Ausführungsbereich öffne und ein WSManConnectionInfo-Objekt mit der PowerSell-URL des Remoteservers bereitstelle.
Ich habe bereits alle möglichen WinRM-Befehle ausprobiert, aber das löst das Problem nicht wirklich. Wie werde ich dieses Problem los?
Antwort1
Warum nicht einfach Enter-PSSession apdv0710.forest7.dom
?
Sie müssen es Enable-PSRemoting
zuerst auf apdv0710.forest7.dom ausführen.
Antwort2
Bei mir hat es funktioniert, indem ich nur den Computernamen und Kerberos als Authentifizierungsmechanismus angegeben habe, zusätzlich zu einem Anmeldeinformationsobjekt, das Benutzername und Passwort enthielt.
New-PSSession -Authentication Kerberos -Computer 'apdv004s' -Cred $credential
Gleiche Verwendung für Enter-PSSession
.