Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reboot a Remote Computer which is not on the Domain

Status
Not open for further replies.

greg0303

Technical User
May 5, 2006
94
CA
I need to reboot computers which are workgroup computers, they are not on the domain were I am rebooting them. I have the local administrator password for these computers but need to know how to convert my normal domain reboot script to reboot computers off the domain. Where would I provide the local Admin credentials?

strComputer = "atl-dc-01"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Shutdown(1)
Next
 
Do you have to use VBScript?

If not, you could just run PSShutDown ( which is free to download and use, from a command prompt, not necessarily with the help of a batch file...

Put the target machine names in a text file (called c:\targets.txt in this example) and use something like this:
Code:
psshutdown -r -f -t 0 @c:\targets.txt
-r means reboot.
-f means Force applications to close
-t 0 means start in zero seconds (without this the default is 20 seconds).

If you want to specify credentials to authorise the reboot command:
Code:
psshutdown -r -f -t 0 -u Administrator -p TheAdministratorPasswordGoesHere @c:\targets.txt
I don't believe the order of the switches matters but I've not tested these lines to confirm.

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top