Search Tools Links Login

PowerShell/WMI to Force Shutdown


You can use this PowerShell and WMI combo one-liner to force a shutdown or restart of a remote computer.

(Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer).Win32Shutdowntracker(0, "This is a custom comment", 0x00000000, 6)

If you need to provide credentials, you can do something like this:

(Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer -Credential $CustomCredentials).Win32Shutdowntracker(0, "This is a custom comment", 0x00000000, 6)

 

About this post

Posted: 2022-09-14
By: dwirch
Viewed: 183 times

Categories

Tip

Scripting

Powershell

PowerShell Code Cache

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.