Solved

Batch Script to shutdown network PCs

Posted on 2014-01-27
2
1,053 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 28

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

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this Micro Tutorial viewers will learn how to use Windows Server Backup to create full image of their system. Tutorial shows how to install Windows Server Backup Feature on Windows 2012R2 and how to configure scheduled Bare Metal Recovery backup.…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now