Questions

Scripting the Shutdown command

Tags:
+
0 Votes
Locked

Scripting the Shutdown command

mtariq
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 <computername> -c "This machine is rebooting."

For <computername>, 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 <computername> 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 <computername>

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