Menu +

Search Posts

Howto: Shutdown remote computer with powershell

Today I was to lazy to walk to my pc and turn it off. I had my laptop next to me and normally I use remote desktop to connect to the pc and open a command line and shutdown /s

Today I thought to use powershell. I need to use it more any way..

To setup a connection and put in commands on the remote pc. Use the following command

Enter-PSSession -Computername <name of pc> -Credentials <username>

A popup will come up to put in the password. It will then connect to that pc and you can start typing in commands. As if you where sitting behind that PC

powershell Enter-pssession

In my case I had already have setup the winrm on the remote┬ácomputer. If you can’t connect then you need to use the following command line on the remote┬ácomputer

Enable-PSRemoting -Force

This command starts the WinRM service, sets it to start automatically with your system, and creates a firewall rule that allows incoming connections. The -Force part of the command tells PowerShell to perform these actions without prompting you for each step.

 

3140 Total Views 3 Views Today

Leave a Comment

Leave a Reply