PowerShell Remoting as a Window’s way to connect to other hosts via CLI. It usually uses WinRM to do so, but can be configured for SSH as well.

To create suh connection, you need few steps:

  1. You need to use ConvertTo-SecureString to make your password into a SecurityString which protects it from being read while in memory.
  2. Then, you pass the password variable into a new PSCredential object. This object is just a standard way of PowerShell for storing creds.
  3. Lastly, you call the Enter-PSSession itself. You add your data there and specify either the hostname or it’s IP.

Word of caution:

  • PowerShell remoting can work weirdly if you don’t have a solid interactive shell - or even better, GUI access - into the system. I expirienced issues when tryint to use it via a bind shell. A good replacement for it is evil-winrm.

$password = ConvertTo-SecureString "qwertqwertqwert123!!" -AsPlainText -Force
 
$cred = New-Object System.Management.Automation.PSCredential("daveadmin", $password)
 
Enter-PSSession -ComputerName CLIENTWK220 -Credential $cred