PowerShell Code: Connect to a Remote Computer Using PowerShell

Today, I’ll show you another classic PowerShell code that will allow you to Connect to a remote machine using PowerShell.

The code, will first ask you for a user name and password and then connect you to the Server.

$cred = Get-Credential
Enter-PSSession -ComputerName server101 -Credential $cred

Note: If the Server Is not a domain join run the extra line below with the Server IP address.

$ip = "192.168.100.2"
Set-Item WSMan:\localhost\Client\TrustedHosts $ip -Confirm:$false

Leave a Reply