Solved

I need a script written to restart MSExchangeMGMT service if it stops...

Posted on 2009-05-07
2
314 Views
Last Modified: 2012-05-06
Hello all!
I am wondering if any of you out in techland can give me acces to a sample script to restart a service if it fails. I am using a managed server system that allows me to use scripts if certain issues arise. The script is basically as follows;

Step one - Check to see if the MSExchangeMGMT service is running.

Step two - If it is running do nothing, if it ISNT running then step three

Step Three - Restart the MSExchangeMGMT service.

The problem is for some reasion this service keeps stopping and I have to manually start it. Not sure what the cause for the stoppage is, no alerts, event log entries, etc; however it does just restart without issues until the next time it stops.

Any help would be greatly appreciated...I will keep scouring the knowledge base!!
0
Comment
Question by:jhalscott
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
zoofan earned 250 total points
ID: 24329554
Copy and paste code into notepad

edit line 7 to correct computer name

save as filename.vbs  execute it



zf
    Option Explicit
    Dim strComputer
    Dim objWMIService
    Dim colServiceList
    Dim objService
            
    strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colServiceList = objWMIService.ExecQuery ("Select * from Win32_Service where Name = 'MSExchangeMGMT'")
        For Each objService In colServiceList
            If objService.State <> "Running" Then
            	objService.StartService()
            End If
        Next
        WScript.Quit(0)

Open in new window

0
 
LVL 12

Assisted Solution

by:zoofan
zoofan earned 250 total points
ID: 24329573
You should also check the recover options under the service properties and make sure its set to restart itself. And clear the fail count.


zf
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

This is a fairly complicated script that will install the required prerequisites to install SCCM 2012 R2 on a server.  It was designed under the functional model in order to compartmentalize each step required, reducing the overall complexity.  The …
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 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