Let’s imagine situation when you have server in domain and you want to execute remote PowerShell commands from the client which is not in the domain. Following recipe shows you how to configure client and server for described scenario.
On the client run PowerShell commands:
1 2 3 | cd wsman:\localhost\Client Set-Item .\AllowUnencrypted -Value $True -Force Set-Item .\TrustedHosts -Value * -Force |
On the server run PowerShell commands:
1 2 | Enable-PSRemoting -Force New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Service -Name allow_unencrypted -Value 1 -PropertyType DWORD |
On the client switch PowerShell provider to file system and run PowerShell commands to test remoting configuration:
1 2 3 | $credential = Get-Credential -Message "Enter credentials" -UserName domain\user Test-WSMan -ComputerName ServerName -Credential $credential -Authentication Negotiate Enter-PSSession -ComputerName ServerName -Credential $credential |
Note that this configuration is intended only for development or testing purposes and is not intended for production use.
If you are interested in PowerShell automation, take my Udemy course Improve your productivity with PowerShell.