Powershell Remote

auf Hostsystem

WinRM konfigurieren

Enable-PSRemoting -force
cd wsman:
Set-Item WSMan:\localhost\Client\TrustedHosts <CLIENT_IP>
restart-Service winrm

auf Clientsystem

Passwort verschlüsselt hinterlegen

Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File C:\Password.txt

Passwort auslesen und Credential Variable erzeugen

$password = type C:\Password.txt | ConvertTo-SecureString
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist “Administrator”,$password

Befehl ausführen

invoke-command <HOSTSYSTEM_IP> -Credential $cred -scriptblock {vzlist -a}

Remote Shell starten

enter-PSSession <HOSTSYSTEM_IP> -Credential $cred