Solved

Batch Script to shutdown network PCs

Posted on 2014-01-27
2
1,076 Views
Last Modified: 2014-02-08
Hi  

I am in a process of choosing a Network PC shutdown software. Meanwhile

I want to run a batch file from my windows 7 PC , so that it can shutdown the chosen network PCs.

If the script cant find the PC It should ignore that PC and shut down the remaining alive PCs.Plaese post me the syntax to do this.

Any help will be grateful.

Many thanks
0
Comment
Question by:lianne143
2 Comments
 
LVL 29

Assisted Solution

by:becraig
becraig earned 200 total points
ID: 39812934
Quick powershell

You need a text file with the list of servers:

$servers = (gc serverlist.txt)
foreach ($server in $servers) 
{while (Test-Connection -computername $Server) {shutdown -r -f -m $server -c "Whatever your reason is for shutdown" }

 }

Open in new window


The -r indicates reboot (Since I doubt you want to keep them switched off)
You can remove it if you only want to shutdown.
0
 
LVL 3

Accepted Solution

by:
SandyWalve earned 200 total points
ID: 39814428
List all the Servers in a Notepad one after the other and save it on your PC from where you can execute this command.

You need to first download PSEXEC. I am assuming you having Local Admin access to all the PC with same account which you are using to execute the command.

psexec @ServerList.txt "shutdown /s"

PSEXEC to download

http://technet.microsoft.com/en-in/sysinternals/bb897553.aspx
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question