Scripting the Shutdown command - TechRepublic
Question
March 8, 2008 at 03:03 AM
mtariq

Scripting the Shutdown command

by mtariq . Updated 13 years, 8 months ago

I have searched everywhere but I cannot find a command-line or PowerShell script that uses the “shutdown” command but interactively takes input for computer name.

I want to do this:

shutdown -r -f -m -c “This machine is rebooting.”

For , I want to pipe it through a text file or interactively enter it at the command prompt when the script is executed.

All I find in reference to shutting down or rebooting computers though scripts are WScripts or VBScripts that are several paragraph long. I am sure there is a simpler way to do it (especially with PowerShell). I can’t figure out how to get PowerShell to take the text that’s entered as a data for the variable. For example:

PS> reboot.bat \\computer01
I want this to run the batch file that has the above shutdown command and places “\\computer01” as the data for variable

Please help if anyone here knows how to do it. Thanks in advance!

This discussion is locked

All Comments