Solved

Powershell Script to Stop / Start / Restart Windows Cluster Services

Posted on 2014-10-06
5
495 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
Comment Utility
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
Comment Utility
Great!  Let me test
0
 

Author Comment

by:mjm21
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Mapping Drives using Group policy preferences Are you still using old scripts to map your network drives if so this article will show you how to get away for old scripts and move toward Group Policy Preference for mapping them. First things f…
Know what services you can and cannot, should and should not combine on your server.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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…

771 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

11 Experts available now in Live!

Get 1:1 Help Now