Powershell remote enabling
I am not able to connect to remote machine using powershell. The procedures i did is:
- Enable-PSRemoting -Force
- Set-Item WSMan:\localhost\Client\TrustedHosts *
- restart-Service winrm
- Enter-PSSession IpAddress
When i run the last step (4th one) from my server machine i am getting an error like:
Enter-PSSessi开发者_高级运维on : Connecting to remote server failed with the following error message : Access is denied.
I have tried all the above 4 steps in both client and server machine. Please help
Thanks Prav
Check the port on the remote machine
PS Z:> cd WSMan:\localhost\Listener
PS WSMan:\localhost\Listener> dir
[cut]
PS WSMan:\localhost\Listener> cd .\Listener_1084132640
PS WSMan:\localhost\Listener\Listener_1084132640> dir
WSManConfig:
Microsoft.WSMan.Management\WSMan::localhost\Listener\Listener_1084132640
Name Value
---- -----
Address *
Transport HTTP
Port 5985
Then connect with the correct port
$remotePowerShellPort = 5985 $ConnectionURI = ("http://{0}:{1}" -f $targetServer, $remotePowerShellPort)
$remoteSession = New-PSSession -ConnectionURI $ConnectionURI
Invoke-Command -Session $remoteSession -ScriptBlock { dir }
Remove-PSSession $remoteSession
精彩评论