[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Looking for a script/powershell to go to a specified number of servers to check if specific services are running and email if not started.

Posted on 2013-06-04
1
Medium Priority
?
337 Views
Last Modified: 2013-08-29
I'm currently looking for a way to run a script/powershell to check a number of windows 2003 servers to see if a specific service is started or not, and return if the service is not started an email to administrators. This would greatly reduced the amount of time it takes to troubleshoot some of my processes
0
Comment
Question by:cgooden01
[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
1 Comment
 
LVL 83

Accepted Solution

by:
David Johnson, CD, MVP earned 900 total points
ID: 39220788
$emailto = "abc@example.com "
$subject = "Stopped Services Report"
$servers = get-content c:\servers.txt
$services = get-content c:\services.txt

foreach ($server in $servers) {
    if (Test-Connection $servers -Count 1 -ErrorAction SilentlyContinue) {
        foreach($service in $services) {
               $status = Get-Service -Name $service -ComputerName $servers -ErrorAction SilentlyContinue
               if ($status.status -eq "Stopped") {
                        $statusmsg = $server + " Service:" + $service + "Is Stopped"
                        Send-MailMessage -To $Emailto -Subject $subject  -From "ServerStatusEmailer@XXXXXXXX" -SmtpServer "XXXXXX" `
                            -Body  $statusmsg -BodyAsHtml
                        }
               }
    }
}

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

649 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