I needed some software/script to shutdown group of chosen computers at a time specified in windows scheduler. I Googled …. and after some research I put this script together:
$erroractionpreference = “SilentlyContinue”
$psSwitches = ” -s -f -c -t 30″
$psMessage = ” -m” + ‘ “Please press CANCEL button if you want to CONTINUE to work. DO NOT forget to shutdown your computer before you leave”‘$strComputer = get-content “computers.txt”
$application = “psshutdown.exe”Foreach ($i in $strComputer)
{
$arguments = “\\$i” + $psSwitches + $psMessage
[System.Diagnostics.Process]::start($application,$arguments)
# write-host $arguments
}
As you can see, I used one of the PSTools applications to do it ![]()
Powershell has it’s own ways to perform the task using Win32Shutdown Method of the Win32_OperatingSystem Class, and I will try it next time…
Tags: PowerShell, remote, shutdown
You must be logged in to post a comment.

No comments
Comments feed for this article
Trackback link: http://mariuszgal.com/blog/wp-trackback.php?p=15