How to shut down Windows Server 2003 without using RDP?
Remote shutdown...
- Using your domain account credentials (if your user account has local admin rights on the target machine):
shutdown /s /f /t 30 /m \\SERVER-NAME
- Using the remote machine's local administrator account (psexec will prompt you for the password):
psexec \\SERVER-NAME -e -h -u SERVER-NAME\administrator shutdown /s /f /t 30
- Using a different domain account:
psexec \\SERVER-NAME -e -h -u DOMAIN-NAME\username shutdown /s /f /t 30
Shutdown parameters explained...
- /s = shutdown (substitute /r if you want to reboot)
- /f = force (don't let running programs or active user sessions interfere with the reboot)
- /t 30 = give logged in users a 30-second warning (substitute any integer, 0 is an acceptable value)
- /m \\SERVER-NAME = specify name of remote machine to reboot
PsExec parameters explained...
- -e = do not load user profile (user profile is unnecessary for shutdown command)
- -h = run task with elevated privileges (only makes a difference on Vista/Win7/Server2008)
- -u SERVER-NAME\administrator = log in as local administrator on SERVER-NAME
- shutdown /s /f /t 30 = i
Batch file example, using local admin account... (paste into Notepad as rsla.bat)
@echo off REM rsla.bat - remote shutdown as local administrator REM This script is freeware authored by Miles Erickson, 7/2010. REM Requires PsExec.exe to be available in %PATH% (c:\windows\system32 is one option) REM Cannot be used to restart a domain controller (domain controllers do not have local admin accounts) IF (%1)==() GOTO instructions IF (%1)==(/?) GOTO instructions psexec \\\\%1 -e -h -u %1\\administrator shutdown /s /f /t 30 GOTO end :instructions ECHO Usage: rsla SERVER-NAME (you will be prompted for a password) :end
Links...
- Download PsExec
If you didn't need to specify credentials, you could use the SHUTDOWN command. If you do need to specify credentials (your login doesn't have permissions, or the computer isn't on the domain), you can use the PSSHUTDOWN utility to do this.
Local account:
cmd /k wmic /node:"targetcomputerhostname" /user:"AdministratororWhatever" os where primary=true call reboot
AD account with local admin privileges:
cmd /k wmic /node:"targetcomputerhostname" /user:"DomainAccountWithAdminPrivs@fqdn" os where primary=true call reboot
This is easily portable as a batch file. Keep in mind you will need the proper remote exceptioins. If psshutdown works, this ought to work as well without installing any external software (not to dis SysInternals tools, the one thing Windows I swear by).
Powershell:
$cred = get-credential Domain\AdminAccount
(gwmi -co %Computername% Win32_OperatingSystem -cr $cred).Shutdown()