Script to run and collect all Exchange performance counters from your environment to server running the tool


Script runs the remote PowerShell session against all Exchange servers, copies the Experfwiz utility to each one and runs performance counters for the time defined by administrator and exports results to the folder, from which it was run.

1. Copy ExPerfWiz.ps1 from: https://experfwiz.codeplex.com/ to some server running Exchange Management Shell to c:\ExchangeHealthCheck
2. Run the script
3. Enter Organization Admin Credentials
4. will be asked to confirm to run perfmon on each server

perfwiz

#Author: Zbynek Salon

#Description: This is small script to collect performace counters from All servrers in your environment to single folder on the server running perfwiz.

#Variables experfwiz

$date = get-date

$UserCredential = Get-Credential

$experfwizstart = $date.AddHours(1)

$experfwizduration = "04:00:00"

$experfwizinterval = 5

$experfwizserver = hostname

$experfwizfilepath = "\\$($experfwizserver)\c$\ExchangeHealthCheck" # zmeneno z c:...

$experfwizmaxsize = 512

###################################################################################################################################################################################################

#Performance counters

$localhost = hostname

$script = get-content "\\$($localhost)\c$\ExchangeHealthCheck\experfwiz.ps1"

$exservers = get-exchangeserver

 foreach ($exsvr in $exservers){

 Write-Host "Processing Exchange server $($exsvr.fqdn) ...."

 Invoke-Command -computername $exsvr.fqdn -ScriptBlock {

 #copying script to EXBIN

 Write-Host "Copying PerfWiz to $($args[1])."

 Test-Path $args[1]

 $exinstall = $args[1]

 $x = $args[0] 

 $x | out-file "$($exinstall)Scripts\experfwiz.ps1"

 Start-Sleep 1

 Write-Host "Importing Exchange PS Session." 

 $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://$($args[8])/PowerShell/" -Authentication Kerberos -Credential $args[9] -AllowRedirection

 Import-PSSession $Session

 cd "$($exinstall)Scripts"

 Set-ExecutionPolicy Unrestricted -Confirm:$false

 .\experfwiz.ps1 -delete #-FilePath $args[5] -Server $args[6] -MaxSize $args[7]

 .\experfwiz.ps1 -Duration "$($args[3])" -interval "$($args[4])" -FilePath "$($args[5])" #-Server "$($args[6])" #-MaxSize $args[7]

 #running perfmon

 } -ArgumentList $script, $exinstall, $experfwizstart, $experfwizduration, $experfwizinterval, $experfwizfilepath, $experfwizserver, $experfwizmaxsize, $exsvr.fqdn, $usercredential

}

##################################################################################################################################################################################################

The script can be downloaded from my OneDrive:
OneDrive

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s