PowerTip: Turn off the power to your computer with PowerShell

Summary: A simple way to power off your computer by using the Windows PowerShell cmdlets.

   Hey, Scripting Guy! I’ve got a script that needs to power off a system after it’s done. How can I accomplish this with PowerShell?

   Look no further than the Stop-Computer cmdlet to turn off the power! (How’s THAT for a power tip?) Here are some examples:

# Try without doing anything bad

Stop-Computer -WhatIf

# Stop the local computer


# Try without doing anything bad on multiple systems

Stop-computer -ComputerName 'computer01','computer02','computer03' -whatif

# Stop multiple systems

Stop-computer -ComputerName 'computer01','computer02','computer03'

Drawing of Dr. Scripto

Comments (1)

  1. Mike Crowley says:

    similarly, If I need to restart the computer “in a while”, after I expect something to be done, I use:

    sleep 3600; restart-computer -force

    Simple but effective.

    There is also the non-powershell:

    shutdown -r -t 3600

Skip to main content