Dgoldman's WebLog

The daily adventures of an Escalation Engineer

How to use the Microsoft Scripting Host (Powershell) to start all of the Exchange Services in one shot

How to use the Microsoft Scripting Host (Powershell) to start all of the Exchange Services in one shot

  • Comments 2

I thought that I would blog on this because this was pretty cool. Before I start the purpose of this blog is to show you that you can manipulate multiple services of the same type. For my test I was debugging a service pack failure which leaves the exchange services status at stopped and the startup type at disabled. For this issue I needed to have all of the services started I set them all to this state on purpose. You will not want to do this to your exchange server unless you are working in the lab under the debugger.

If you ever get to a point where any or all of your Exchange Services or any other services for that matter are disabled and or disabled and stopped you can run the following commands manipulate them.

Since I ran services.msc I was already able to see that all of my Exchange services were stopped and their startup type was set to disabled. This can be a huge pain because before Powershell you would need to either write a script to start all of them and set them to Automatic, or select each one and fix them.

In this case I wanted to show everybody what I was seeing so I will verify this via Powershell. If you run the following command you can get the service's status:

[PS] C:\>Get-Service *Exchange* | ft -Wrap

Status      Name                                                    DisplayName
Stopped  MSExchangeADTopology                 Microsoft Exchange Active Directory Topology Service
Stopped  MSExchangeAntispamUpdate        Microsoft Exchange Anti-spam Update
Stopped  MSExchangeEdgeSync                     Microsoft Exchange EdgeSync
Stopped  MSExchangeFDS                                Microsoft Exchange File Distribution
Stopped  MSExchangeImap4                            Microsoft Exchange IMAP4
Stopped  MSExchangeIS                                    Microsoft Exchange Information Store
Stopped  MSExchangeMailboxAssistants       Microsoft Exchange Mailbox Assistants
Stopped  MSExchangeMailSubmission          Microsoft Exchange Mail Submission
Stopped  MSExchangeMonitoring                     Microsoft Exchange Monitoring
Stopped  MSExchangePop3                              Microsoft Exchange POP3
Stopped  MSExchangeRepl                               Microsoft Exchange Replication Service
Stopped  MSExchangeSA                                   Microsoft Exchange System Attendant
Stopped  MSExchangeSearch                           Microsoft Exchange Search Indexer
Stopped  MSExchangeServiceHost                  Microsoft Exchange Service Host
Stopped  MSExchangeTransport                      Microsoft Exchange Transport
Stopped  MSExchangeTransportLogSearch  Microsoft Exchange Transport Log Search
Stopped  msftesql-Exchange                            Microsoft Search (Exchange)

One thing that stinks is that there is no way possible via Powershell to show the services startup type (automatic, disabled, manual, etc) without the use of WMI. You can get the StartMode in PowerShell through a WMI query: Get-WmiObject Win32_Service -filter "Name like '%Exchange%'" | ft -AutoSize Name, StartMode

Now I want to set all of the services start up type in one shot to Automatic. You run the following command with the verbose parameter (-vb) to do so:

[PS] C:\>get-service *exchange* | Set-Service -StartupType Automatic -vb
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Active Directory Topology Service (MSExchangeADTopology)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Anti-spam Update (MSExchangeAntispamUpdate)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange EdgeSync (MSExchangeEdgeSync)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange File Distribution (MSExchangeFDS)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange IMAP4 (MSExchangeImap4)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Information Store (MSExchangeIS)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Mailbox Assistants (MSExchangeMailboxAssistants)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Mail Submission (MSExchangeMailSubmission)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Monitoring (MSExchangeMonitoring)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange POP3 (MSExchangePop3)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Replication Service (MSExchangeRepl)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange System Attendant (MSExchangeSA)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Search Indexer (MSExchangeSearch)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Service Host (MSExchangeServiceHost)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Transport (MSExchangeTransport)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Exchange Transport Log Search (MSExchangeTransportLogSearch)".
VERBOSE: Performing operation "Set-Service" on Target "Microsoft Search (Exchange) (msftesql-Exchange)".

Once this is done you will need to manually verify the results by running services.msc. Now that I have verified this I want to start them all in one shot. I run the following command again using the verbose parameter (-vb):

[PS] C:\>get-service *exchange* | Start-Service -vb
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Active Directory Topology Service (MSExchangeADTopology)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Anti-spam Update (MSExchangeAntispamUpdate)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange EdgeSync (MSExchangeEdgeSync)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange File Distribution (MSExchangeFDS)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange IMAP4 (MSExchangeImap4)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Information Store (MSExchangeIS)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Mailbox Assistants (MSExchangeMailboxAssistants)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Mail Submission (MSExchangeMailSubmission)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Monitoring (MSExchangeMonitoring)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Replication Service (MSExchangeRepl)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange System Attendant (MSExchangeSA)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Search Indexer (MSExchangeSearch)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Service Host (MSExchangeServiceHost)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Exchange Transport Log Search (MSExchangeTransportLogSearch)".
VERBOSE: Performing operation "Start-Service" on Target "Microsoft Search (Exchange) (msftesql-Exchange)".
[PS] C:\>

The last portion is to make sure that the command work properly.

[PS] C:\>Get-Service *Exchange* | ft -Wrap

Status     Name                                                    DisplayName
Running  MSExchangeADTopology                 Microsoft Exchange Active Directory Topology Service
Running  MSExchangeAntispamUpdate        Microsoft Exchange Anti-spam Update
Running  MSExchangeEdgeSync                     Microsoft Exchange EdgeSync
Running  MSExchangeFDS                                Microsoft Exchange File Distribution
Running  MSExchangeImap4                            Microsoft Exchange IMAP4
Running  MSExchangeIS                                    Microsoft Exchange Information Store
Running  MSExchangeMailboxAssistants       Microsoft Exchange Mailbox Assistants
Running  MSExchangeMailSubmission          Microsoft Exchange Mail Submission
Running  MSExchangeMonitoring                     Microsoft Exchange Monitoring
Running  MSExchangePop3                              Microsoft Exchange POP3
Running  MSExchangeRepl                               Microsoft Exchange Replication Service
Running  MSExchangeSA                                   Microsoft Exchange System Attendant
Running  MSExchangeSearch                           Microsoft Exchange Search Indexer
Running  MSExchangeServiceHost                  Microsoft Exchange Service Host
Running  MSExchangeTransport                      Microsoft Exchange Transport
Running  MSExchangeTransportLogSearch  Microsoft Exchange Transport Log Searc
Running  msftesql-Exchange                            Microsoft Search (Exchange)

Dave

Comments
Page 1 of 1 (2 items)