Remote Session Powershell

Like ssh you can run a remote session in powershell.

Test if remote session is enabled
#Test-WsMan [Computername]

If you get a result, it should be up and running. Otherwise you need to activate it on the remote server like this.

Enable PowerShell Remoting on a Server
1. Run Powershell as an administrator
2. #Enable-PSRemoting –Force
This command starts the WinRM server service and sets it automatically to start with the system. It also creates a firewall rule that allows incoming connections.

Workgroup
If your computers aren’t in a domain you need to do a couple of more steps to make a trust between them. You need to edit the TrustedHosts on both sides. You could put the IP Adresses comma-seperated instead of * to further restrict it. With the * it will allow any host.

1. #Set-Item wsman:\localhost\client\trustedhosts *
2. #Restart-Service WinRM

Execute a Remote Command
#Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } -credential USERNAME

Start a Remote Session
#Enter-PSSession -ComputerName COMPUTER -Credential USERNAME

admin on February 8th 2013 in PowerShell

No Comments »

Comments RSS

Leave a Reply

*




Check out new movies online website. Download and buy movies now.
1