Enable PowerShell Remoting on non-domain server
Here a quick ‘how to’ connect to a remote server via PowerShell that is not joined to a domain.
**
On remote server:
** 1. Make sure the Windows Remote Management (winrm) service is running
# Get the status of the winrm service Get-Service winrm # If it not running, start the service Start-Service winrm # Also set the service to start automatically (Delayed Start) Set-Service "winrm" -StartupType Automatic # Enable winrm winrm quickconfig
- Make sure your network connection type is private
# To see if it's set to private or not run this Get-NetConnectionProfile # To set it to Private, run this (as admin) Set-NetConnectionProfile -NetworkCategory Private
- Enable PowerShell remoting
Enable-PSRemoting -Force
**
On local computer:
**
- Make sure the Windows Remote Management (winrm) service is running
# Get the status of the winrm service Get-Service winrm # If it not running, start the service Start-Service winrm # Also set the service to start automatically (Delayed Start) Set-Service "winrm" -StartupType Automatic
- Add the ‘remote server’ to the trusted host list
# Add your 'remote server's' IP to the trusted host list Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.1.1" -Force # Or if IPs are constantly changing, add ALL IPs (* is the wildcard) Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force # Check and make sure the right value is in the trusted host list Get-Item WSMan:\localhost\Client\TrustedHosts # To clear the trusted host list, run this Set-Item WSMan:\localhost\Client\TrustedHosts -Value "" -Force
Connect to your remote server:
# If you are in CLI Enter-PSSession -ComputerName 192.168.1.1 -Credential Get-Credential # If you are in the ISE $credential = Get-Credential Enter-PSSession -ComputerName 192.168.1.1 -Credential $credential
If everything went right, you should see a prompt showing the remote PC IP
# e.g. like this: [192.168.1.1]: PS C:\Users\Administrator>