Difference between revisions of "Powershell Remote Access"

From Michael's Information Zone
Jump to navigation Jump to search
Line 8: Line 8:
 
<ref>https://4sysops.com/archives/use-powershell-invoke-command-to-run-scripts-on-remote-computers/</ref>Of course Microsoft would give  you more options than you really need. If only we were on SSH already....
 
<ref>https://4sysops.com/archives/use-powershell-invoke-command-to-run-scripts-on-remote-computers/</ref>Of course Microsoft would give  you more options than you really need. If only we were on SSH already....
 
<pre>
 
<pre>
c
+
New-PSSession -ComputerName COMPUTER - Credential USER
Enter-PSSession -ComputerName COMPUTER -Credential USER
+
Enter-PSSession -ComputerName COMPUTER
 +
Remove-PSSession -ComputerName COMPUTER
 +
</pre>
 +
<pre>
 +
Invoke-Command -ComputerName COMPUTER -ScriptBlock {Get-Process}
 
</pre>
 
</pre>

Revision as of 15:36, 14 June 2017

[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}