Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Batch Script to shutdown network PCs

Posted on 2014-01-27
2
Medium Priority
?
1,146 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 800 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 800 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

782 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