Solved

Powershell Script to Stop / Start / Restart Windows Cluster Services

Posted on 2014-10-06
5
613 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
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…
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 …

830 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