PowerShell Remote Commands

,

This is something I've found useful here recently when I had a server acting up. It's a simple way to send commands to a remote server such as 'shutdown -r'

Enable-PSRemoting -Force
Enables to you actually remote through PowerShell.
Test-WSMan Server1
Just tests that you can reach the server through this method.
Invoke-Command -ComputerName Server1 -ScriptBlock { Get-ChildItem C:\ } -credential Domain\UsrID
If you're only sending a single command, you'd replace the Get-ChildItem C:\" with what you're wanting to run.
Enter-PSSession -ComputerName Server1 -Credential Domain\UsrID
This command allows me to interact on a long term method. Basically if I'm sending more than a single command, this would work better.
I'm sure there are other methods. I like short concise code. How do you all connect?

Rate

Share

Share

Rate