PowerTip: Turn off the power to your computer with PowerShell

Doctor Scripto

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

Stop-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