Activar control remot Powershell

Per poder obrir sessions remotes a un Powershell hem de fer diverses configuracions.

Primer de tot hem d’activar l’accés remot al client. Per fer-ho executem el Powershell com a administrador i executem:

Enable-PSRemoting -Force

Un cop activat l’accés remot hem d’afegir els dos ordinadors a la llista de confiança, per tant executem la mateixa comanda al servidor i al client:

Set-Item wsman:\localhost\client\trustedhosts *

Reiniciem el client i un cop engegat tornem a obrir el Powershell com a administrador i executem:

winrm quickconfig

Per executar comandes remotament:

Invoke-Command -ComputerName <ordinador> -ScriptBlock { <comanda> } -Credential <usuari>