?
Solved

Powershell Script to Stop / Start / Restart Windows Cluster Services

Posted on 2014-10-06
5
Medium Priority
?
800 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
OriNetworks earned 1000 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

743 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