Powershell Remote Access

From Michael's Information Zone
Revision as of 15:43, 14 June 2017 by Michael.mast (talk | contribs) (→‎On client)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

[1][2]

On server

enable-psremoting -force
winrm set winrm/config/client '@{TrustedHosts="machineA,machineB"}'

On client

[3]Of course Microsoft would give you more options than you really need. If only we were on SSH already....

New-PSSession -ComputerName COMPUTER - Credential USER
Enter-PSSession -ComputerName COMPUTER
Remove-PSSession -ComputerName COMPUTER
Invoke-Command -ComputerName COMPUTER -ScriptBlock {Get-Process}

Or even better

Invoke-Command -ComputerName PC1,PC2,PC3 -FilePath C:\myFolder\myScript.ps1