Enable-PSRemoting

How to enable PSRemoting and control remote computer.

Enable-PSRemoting -Force # Enable WinRM service, adds exception to firewall
Set-Item wsman:localhostclienttrustedhosts * # IP address, hostname, subnet, * all computers - needs to be trusted on both sides if you don't use domain Auth
Restart-Service WinRM
Test-WsMan REMOTECOMPUTER
Invoke-Command -ComputerName REMOTECOMPUTER -ScriptBlock { hostname } -credential REMOTEUSER
Enter-PSSession -ComputerName REMOTECOMPUTER -Credential REMOTEUSER
Clear-Item WSMan:localhostClientTrustedHosts # Clear all trusted Hosts

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.