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

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

  1. check now October 7, 2014 at 10:53 am Reply

    I couldn’t refrain from commenting. Perfectly written!

    Like

  2. baju bayi murah October 7, 2014 at 1:47 pm Reply

    I am actually grateful to the holder of this site who has shared this fantastic piece of writing at at this place.

    Like

  3. Rodrick October 7, 2014 at 10:18 pm Reply

    It’s remarkable in support of me to have a website, which is good in favor of
    my know-how. thanks admin

    Like

  4. bible app October 9, 2014 at 5:31 am Reply

    Excellent site. Plenty of useful information here. I’m
    sending it to several friends ans additionally sharing in delicious.
    And obviously, thank you in your effort!

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.