Powershell Script for Baselining Lync Rev 1.0

So as you can guess i am on a journey about learning powershell and i am trying to do things which might be useful.

This is a straight forward piece of script to help you baseline you lync installation.

My next edits to this script will output to files for comparison later and also i am going to section things into functions and also create a little menu system but here it the bones of a working script as it is… enjoy!

write-host “Welcome to the resource utilization baseline test” -Foregroundcolor Green -Backgroundcolor Black
write-host “Please confirm how long you want these tests to run for” -Foregroundcolor Green -Backgroundcolor Black
write-host “For exampe you may want to sample every 1 second for a max samples of 1000″ -Foregroundcolor Green -Backgroundcolor Black
write-host “This will give you 1000seconds of samples… you may want this longer” -Foregroundcolor Green -Backgroundcolor Black
write-host “depending on the environmnet” -Foregroundcolor Green -Backgroundcolor Black
write-host “Comments and Suggestions to johm@microsoft.com or on Twitter: @mccabej” -foregroundcolor Yellow -backgrouncolor red
write-host “Please be kind i am still learning powershell :) ” -foregroundcolor Yellow -backgrouncolor red
write-host
$sampleinttime = Read-host (“Please enter how often you want to sample in secs and press enter:”)
$maxsamp = Read-host (“Please enter the amount of samples you want to take and press enter:”)

write-host “Performing Resource Utilization Baseline Tests…….” -Foregroundcolor Green -Backgroundcolor Blue
write-host
write-host
write-host
$result = get-counter -counter “\Processor(_total)\% Processor Time” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$proctimetotal = $avg.average
write-host “Baseline Processor Time Overall” $proctimetotal -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(RTCSRV)\% Processor Time” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$proctimertcsrv = $avg.average
write-host “Baseline Processor Time for RTCSRV” $proctimertcsrv -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(IMMcuSvc)\% Processor Time” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$proctimeimmcusvc = $avg.average
write-host “Baseline Processor Time IMMcuSvc” $proctimeimmcusvc -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Memory\Pages/sec” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$mempages = $avg.average
write-host “Baseline for Memory Pages/sec” $mempages -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Network Interface(*)\Bytes Total/sec” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$netint = $avg.average
write-host “Baseline For Network Interfces Bytes Total/sec” $netint -Foregroundcolor Green -Backgroundcolor Blue

write-host
write-host
write-host
write-host “Performing User Load Baseline Tests…….” -Foregroundcolor Green -Backgroundcolor Blue
write-host
write-host

write-host

$result = get-counter -counter “\LS:SIP – 01 – Peers(*)\SIP – 001 – TLS Connections Active” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$tlsconnectionsactive = $avg.average
write-host “Baseline SIP – 001 – TLS Connections Active” $tlsconnectionsactive -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\LS:SIP – 01 – Peers(*)\SIP – 000 – Connections Active” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$connectionsactive = $avg.average
write-host “Baseline SIP – 000 – Connections Active” $connectionsactive -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\LS:SIP – 02 – Protocol\SIP – 001 – Incoming Messages/sec” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$incomingmsgpersec = $avg.average
write-host “Baseline SIP – 001 – Incoming Messages/sec” $incomingmsgpersec -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\LS:ImMcu – 00 – IMMcu Conferences\IMMCU – 000 – Active Conferences” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$immcuactiveconf = $avg.average
write-host “Baseline ImMCU Active Conferences” $immcuactiveconf -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\LS:ImMcu – 00 – IMMcu Conferences\IMMCU – 001 – Connected Users” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$immcuconusers = $avg.average
write-host “Baseline ImMCU Connected Users” $imccuconusers -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\LS:USrv – 00 – REGDBStore\USrv – 002 – Queue Latency (msec)” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$queuelatency = $avg.average
write-host “Baseline USrv – Queue Latency” $queuelatency -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\LS:USrv – 00 – REGDBStore\USrv – 004 – Sproc Latency (msec)” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$sproclatency = $avg.average
write-host “Baseline USrv – Sproc Latency” $sproclatency -Foregroundcolor Green -Backgroundcolor Blue

write-host
write-host
write-host
write-host “Performing Multipoint Conferencing Unit Resource Baseline Tests…….” -Foregroundcolor Green -Backgroundcolor Blue
write-host
write-host

write-host

$result = get-counter -counter “\Memory\Pages/sec” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$mempages = $avg.average
write-host “Baseline for Memory Pages/sec” $mempages -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Network Interface(*)\Bytes Total/sec” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$netint = $avg.average
write-host “Baseline For Network Interfces Bytes Total/sec” $netint -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Processor(_total)\% Processor Time” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$proctimetotal = $avg.average
write-host “Baseline Processor Time Overall” $proctimetotal -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(ASMCUSVC)\% Processor Time” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$asmcusvc = $avg.average
write-host “Baseline Processor Time for ASMCUSVC” $asmcusvc -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(AVMCUSVC)\% Processor Time” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$avmcusvc = $avg.average
write-host “Baseline Processor Time for AVMCUSVC” $avmcusvc -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(DataMCUsvc)\% Processor Time” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$datamcusvc = $avg.average
write-host “Baseline Processor Time for Datamcusvc” $datamcusvc -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(meetingmcusvc)\% Processor Time” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$meetingmcusvc = $avg.average
write-host “Baseline Processor Time for meetingmcusvc” $meetingmcusvc -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(ASMCUSVC)\Private Bytes” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$asmcusvcpb = $avg.average
write-host “Baseline Private Bytes for ASMCUSVC” $asmcusvcpb -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(AVMCUSVC)\Private Bytes” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$avmcusvcpb = $avg.average
write-host “Baseline Private Bytes for AVMCUSVC” $avmcusvc -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(DataMCUsvc)\Private Bytes” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$datamcusvcpb = $avg.average
write-host “Baseline Private Bytes for Datamcusvc” $datamcusvc -Foregroundcolor Green -Backgroundcolor Blue

$result = get-counter -counter “\Process(meetingmcusvc)\Private Bytes” -sampleinterval $sampleinttime -maxsample $maxsamp
$avg = $Result | Foreach-object {$_.CounterSamples}| Measure-object -Property CookedValue -Average
$meetingmcusvcpb = $avg.average
write-host “Baseline Private Bytes for meetingmcusvc” $meetingmcusvc -Foregroundcolor Green -Backgroundcolor Blue