Enabling PowerShell Remoting
suggest changePowerShell remoting must first be enabled on the server to which you wish to remotely connect.
Enable-PSRemoting -Force
This command does the following:
- Runs the Set-WSManQuickConfig cmdlet, which performs the following tasks:
- Starts the WinRM service.
- Sets the startup type on the WinRM service to Automatic.
- Creates a listener to accept requests on any IP address, if one does not already exist.
- Enables a firewall exception for WS-Management communications.
- Registers the Microsoft.PowerShell and Microsoft.PowerShell.Workflow session configurations, if it they are not already registered.
- Registers the Microsoft.PowerShell32 session configuration on 64-bit computers, if it is not already registered.
- Enables all session configurations.
- Changes the security descriptor of all session configurations to allow remote access.
- Restarts the WinRM service to make the preceding changes effective.
Only for non-domain environments
For servers in an AD Domain the PS remoting authentication is done through Kerberos (‘Default’), or NTLM (‘Negotiate’). If you want to allow remoting to a non-domain server you have two options.
Either set up WSMan communication over HTTPS (which requires certificate generation) or enable basic authentication which sends your credentials across the wire base64-encoded (that’s basically the same as plain-text so be careful with this).
In either case you’ll have to add the remote systems to your WSMan trusted hosts list.
Enabling Basic Authentication
Set-Item WSMan:\localhost\Service\AllowUnencrypted $true
Then on the computer you wish to connect from, you must tell it to trust the computer you’re connecting to.
Set-Item WSMan:\localhost\Client\TrustedHosts '192.168.1.1,192.168.1.2'
Set-Item WSMan:\localhost\Client\TrustedHosts *.contoso.com
Set-Item WSMan:\localhost\Client\TrustedHosts *
Important: You must tell your client to trust the computer addressed in the way you want to connect (e.g. if you connect via IP, it must trust the IP not the hostname)