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

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • Bob Jo 0

    hey Scripting Guy –  What a great tip !!  Thanks.   Now, how about a script to start the remote computer after I have used this script to shut it down ??   You know, kinda like the old  WOL  used to do.  That would really be nice !!!  and convenient !!!   Would save lots of driving time.   Looking forward to seeing your solution …

Feedback usabilla icon