Difference between revisions of "Powershell Remote Access"
Jump to navigation
Jump to search
Michael.mast (talk | contribs) |
Michael.mast (talk | contribs) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <ref>https://stackoverflow.com/questions/21548566/how-to-add-more-than-one-machine-to-the-trusted-hosts-list-using-winrm</ref> | + | <ref>https://stackoverflow.com/questions/21548566/how-to-add-more-than-one-machine-to-the-trusted-hosts-list-using-winrm</ref><ref>https://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/</ref> |
+ | ==On server== | ||
<pre> | <pre> | ||
enable-psremoting -force | enable-psremoting -force | ||
winrm set winrm/config/client '@{TrustedHosts="machineA,machineB"}' | winrm set winrm/config/client '@{TrustedHosts="machineA,machineB"}' | ||
+ | </pre> | ||
+ | ==On client== | ||
+ | <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> | ||
+ | New-PSSession -ComputerName COMPUTER - Credential USER | ||
+ | Enter-PSSession -ComputerName COMPUTER | ||
+ | Remove-PSSession -ComputerName COMPUTER | ||
+ | </pre> | ||
+ | <pre> | ||
+ | Invoke-Command -ComputerName COMPUTER -ScriptBlock {Get-Process} | ||
+ | </pre> | ||
+ | Or even better | ||
+ | <pre> | ||
+ | Invoke-Command -ComputerName PC1,PC2,PC3 -FilePath C:\myFolder\myScript.ps1 | ||
</pre> | </pre> |
Latest revision as of 15:43, 14 June 2017
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
- ↑ https://stackoverflow.com/questions/21548566/how-to-add-more-than-one-machine-to-the-trusted-hosts-list-using-winrm
- ↑ https://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/
- ↑ https://4sysops.com/archives/use-powershell-invoke-command-to-run-scripts-on-remote-computers/