Script to fix issues described in KB2603670 (PowerShell)
Introduction
This sample can help you to resolve the issue “Services Required for the Microsoft Exchange Server Are Not Started” which is described in KB2603670. It shows how to list and start all services that are not running but required for Exchange
Servers by using PowerShell script.
Scenarios
The service which is required for your Exchanger Server is set to start automatically, but it is not currently running. In this case, the Exchange Server will not work correctly. To resolve this issue, you can use this script to list and start all services
that are not running but required for Exchange Server.
Script
This script contains the following advanced functions:
You can use this script in the following ways (You need run the script as administrator):
Method 1:
-
Download the script and copy it to your computer.
-
Open the script file by using Notepad or any other script editors.
-
Scroll down to the end of the script file, and then add the code to call the functions.
-
Save the file and then run the script on the computer.
Method 2:
-
Rename scriptname.ps1 to scriptname.psm1 (PowerShell Module file)
-
Run the Import-Module cmdlet to import this module file in PowerShell Console.
Import-Module filepath\scriptname.psm1
To obtain the detailed information about how to use the functions, run the following command to retrieve the help information:
Get-Help functionName -detailed
For example:
Get-Help Get-OSCServicesNotRunning -detailed
Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
PowerShell
Edit|Remove
powershell
Foreach($OSCExchangeServer in $OSCExchangeServers){
$OSCRolesServiceHealth = Test-ServiceHealth -Server $OSCExchangeServer.Name -ErrorAction SilentlyContinue
ForEach($OSCRoleServiceHealth in $OSCRolesServiceHealth){
If($OSCRoleServiceHealth.RequiredServicesRunning -ne $true){
ForEach($OSCStrRequiredService in $OSCRoleServiceHealth.ServicesNotRunning){
IF($OSCStrServicesNotRunning -notcontains $OSCStrRequiredService)
{
$OSCStrServicesNotRunning += $OSCStrRequiredService
}
}
}
}
ForEach($OSCStrRequiredService in $OSCStrServicesNotRunning){
$OSCService = Get-Service -ComputerName $OSCExchangeServer.Name -Name $OSCStrRequiredService -ErrorAction SilentlyContinue
$OSCExchageService = New-Object PSObject
$OSCExchageService | Add-Member NoteProperty "Name" $null
$OSCExchageService | Add-Member NoteProperty "DisPlayName" $null
$OSCExchageService | Add-Member NoteProperty "Status" $null
$OSCExchageService | Add-Member NoteProperty "Server" $null
$OSCExchageService | Add-Member NoteProperty "Domain" $null
$OSCExchageService.Name = $OSCService.Name
$OSCExchageService.DisPlayName = $OSCService.DisPlayName
$OSCExchageService.Status = $OSCService.Status
$OSCExchageService.Server = $OSCExchangeServer.Name
$OSCExchageService.Domain = $OSCDomain
$OSCObjServicesNotRunning += $OSCExchageService
}
$OSCStrServicesNotRunning = @()
}
Foreach($OSCExchangeServer in $OSCExchangeServers){
$OSCRolesServiceHealth = Test-ServiceHealth -Server $OSCExchangeServer.Name -ErrorAction SilentlyContinue
ForEach($OSCRoleServiceHealth in $OSCRolesServiceHealth){
If($OSCRoleServiceHealth.RequiredServicesRunning -ne $true){
ForEach($OSCStrRequiredService in $OSCRoleServiceHealth.ServicesNotRunning){
IF($OSCStrServicesNotRunning -notcontains $OSCStrRequiredService)
{
$OSCStrServicesNotRunning += $OSCStrRequiredService
}}}}
ForEach($OSCStrRequiredService in $OSCStrServicesNotRunning){
$OSCService = Get-Service -ComputerName $OSCExchangeServer.Name -Name $OSCStrRequiredService -ErrorAction SilentlyContinue
$OSCExchageService = New-Object PSObject
$OSCExchageService | Add-Member NoteProperty "Name" $null
$OSCExchageService | Add-Member NoteProperty "DisPlayName" $null
$OSCExchageService | Add-Member NoteProperty "Status" $null
$OSCExchageService | Add-Member NoteProperty "Server" $null
$OSCExchageService | Add-Member NoteProperty "Domain" $null
$OSCExchageService.Name = $OSCService.Name
$OSCExchageService.DisPlayName = $OSCService.DisPlayName
$OSCExchageService.Status = $OSCService.Status
$OSCExchageService.Server = $OSCExchangeServer.Name
$OSCExchageService.Domain = $OSCDomain
$OSCObjServicesNotRunning += $OSCExchageService
}
$OSCStrServicesNotRunning = @()
}
Examples
Example 1: List all services which are required but not running for all Exchange Servers in the current Domain
Command: Get-OSCServicesNotRunning
Screenshot:

Example 2: List all services which are required but not running for a specific Exchange Server
Command: Get-OSCServicesNotRunning –ServerName <Exchange Server Name>
Screenshot:

Example 3: Start all services which are required but not running for all Exchange Servers in the current Domain
Command: Start-OSCServicesNotRunning
Screenshot:

Example 4: Start all services which are required but not running for a specific Exchange Server
Command: Start-OSCServicesNotRunning –ServerName <Exchange Server Name>
Screenshot:
Prerequisites
Windows PowerShell 2.0
Microsoft Exchange Server 2010
Additional Resources
Technical Resources: