Solved

Powershell Script to Stop / Start / Restart Windows Cluster Services

Posted on 2014-10-06
5
527 Views
Last Modified: 2014-10-16
Looking for a Powershell Script that would take the content of server names in a .txt file and Stop / Start / Restart Windows Cluster Services on 2003, 2008, and 2012
0
Comment
Question by:mjm21
  • 2
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
OriNetworks earned 250 total points
ID: 40363673
Put a list of hosts in a txt file. Replace MyService with the name of the service you want to restart.
$hosts = Get-Content MyHosts.txt
foreach ($i in $hosts)
{
Write-Output "restarting service on $i"
Get-Service -Name MyService -ComputerName $i | Stop-service
Get-Service -Name MyService -ComputerName $i | Start-service
}

Open in new window

0
 

Author Comment

by:mjm21
ID: 40363684
Great!  Let me test
0
 

Author Comment

by:mjm21
ID: 40363714
Works great on my local machine but did not work on my remote neighbor's.
0
 
LVL 16

Assisted Solution

by:Joshua Grantom
Joshua Grantom earned 250 total points
ID: 40363740
Hello mjm21 and OriNetworks,

Here is a slightly different method. Let me know if this works better, its based off of another question I helped with

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/Q_28523050.html

$hosts = Get-Content MyHosts.txt
foreach ($i in $hosts)
{
Write-Output "restarting service on $i"
Restart-Service -InputObject $(Get-Service -Computer $i -Name MyService)
}

Open in new window

0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40363788
Just an fyi: you would need the proper rights on the remote system to restart the service possibly by being a local administrator in order for this to work. Thanks Joshua for the enhanced version.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

If, like me, you have a lot of Dell servers in the estate you manage this article should save you a little time. When attempting to login to iDrac on any server I would be presented with two errors. The first reads "Do you want to run this applicati…
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

912 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

23 Experts available now in Live!

Get 1:1 Help Now