开发者

Powershell remote enabling

开发者 https://www.devze.com 2023-02-20 10:58 出处:网络
I am not able to connect to remote machine using powershell. The procedures i did is: Enable-PSRemoting -Force

I am not able to connect to remote machine using powershell. The procedures i did is:

  1. Enable-PSRemoting -Force
  2. Set-Item WSMan:\localhost\Client\TrustedHosts *
  3. restart-Service winrm
  4. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消