Category Archives: Perfmon

Script to Start, Stop and query exchange counters on all Exchange servers

I have developed a script which can be used to Query, Start and Stop Exchange counters on all servers in Exchange environment.

This script can be executed in scenarios where we need to enable Perfmon counters for Exchange on all Exchange servers during troubleshooting scenarios.

Copy the list of Exchange servers for which we need to run Perfmon and save them in a notepad in the below format in the server where you are going to execute this command.

Scrip1

 

Probably if you have difficulty in collecting the list of servers manually we can run the below command and take the output by running the below command.

Get-ExchangeServer | select name  >c:\servers.txt

Once you get the output just format the text file and ensure no spaces and other characters are present apart from servers as above screenshot.

 

Copy the below text and save it in ps1 file. Ensure you change the server path alone in this script which has the server list.

 

***************************************************************************

write-host ”

1.List Available Counters for Exchange_All

2.Start Counter for  Exchange_All

3.Stop Counter for Exchange_All

$option = Read-host

$server = get-content “Example- d:\exserver.txt”

switch ($option)

 

{

 

1

 

{

 

$server | foreach {logman query Exchange_All -s $_}

 

 

}

 

2

{

 

$server | foreach {logman start Exchange_All -s $_}

 

}

 

3

 

{

 

$server | foreach {logman stop Exchange_All -s $_}

}

 

4

 

{

}

 

}

********************************************************************************

Navigate to the location where we have this file saved and run.

We will get 3 available options as below.

Option 1 –  To List Available Counters for Exchange_All

Option 2 – To Start Counter for Exchange_All

Option 3 – To Stop Counter for Exchange_All

 

scrip2

 

Choose the required option and the command will be executed accordingly.

Below is example for querying the Perfmon counters for Exchange_All in all exchange servers.

script3

 

 

Below is example for starting the Perfmon counters for Exchange_All in all exchange servers.

scrip4

Below is example for stopping the Perfmon counters for Exchange_All in all exchange servers

scrip5

This command can be useful when we might need to enable Perfmon on multiple exchange servers at one time in troubleshooting scenarios.

Thanks

Sathish Veerapandian

%d bloggers like this: