Tag Archive: powershell


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

Advertisements

i am adding to this script but take it and try it out for yourself…

#****************************************************************

# This script will test direct access
# it is very much work in progress and will be modified…
# at the minute this script will test which tunnel mode you are using
# i have a deep problem into teredo and will do the reset!

$useteredo = “0”
$use6to4 = “0”
$usehttps = “0”

$6to4 = netsh interface 6to4 show state
write-host “Checking to see if you are using 6to4……..”
Foreach ($6 in $6to4)
{
if ($6 -match “disabled”)
{
write-host “6to4 protocol is disabled”
write-host “You must be behind a NAT Device..”
}
else
{
$use6to4 = “1”
}

}

$teredo = netsh interface teredo show state
write-host “Checking to see if you are using teredo……..”
Foreach ($t in $teredo)
{
if ($t -match “disabled”)
{
write-host “Teredo protocol is disabled”
write-host “Your NAT Device Seems to be blocking UDP 3544”
}
else
{
$useteredo = “1”

}

}

$iphttps = netsh interface httpstunnel show interface

Foreach ($i in $iphttps)
{
 

if ($i -match “disabled”)
{
write-host “IPHTTPS protocol is disabled”

}

else
{
$usehttps = “1”

}

}

if($useteredo -eq “1”)
{
write-host “You are using Teredo”
$teredo1 = netsh interface teredo show state
$teredo2 = $teredo1 | where-object {$_ -match “Server Name”} |foreach-object {$_.Split(“:”)[1].Trim()}
$teredo3 = $teredo2.split(“(“)
Write-Host
Write-Host
Write-host “Direct Access Public Hostname is…. :” $teredo3[0]
Write-Host
Write-Host “Pinging host….” $teredo3[0]
$ping = ping $teredo3
$ping1 = $ping | Where-Object{ $_ -match “Request”}
$ping2 = $ping | Where-Object{ $_ -match “Reply”}
Write-Host
Write-Host
if ($ping1 -ne $null)
{
write-host $teredo3[0] “could not be contacted”
$noreach = 1
}
elseif ($ping2 -ne $null)
{
Write-Host $teredo3[0] “could be reached”
$noreach = 0
}

if ($noreach = 1)
{
write-host “Testing Internet Connection…..”
$testhost = “tpm.daccess.microsoft.com”
$inettest = ping $testhost
$inettest1 = $inettest | Where-Object{ $_ -match “Reply”}

if ($inettest1 -ne $null)
{
Write-Host “You have a connection to the internet!”
}
else {write-host ” you have no internet connection please check with your provider”}
}

}
elseif($use6to4 -eq “1”)
{
write-host “You are using 6to4”
}
elseif($usehttps -eq “1”)
{
write-host “You are using HTTPSTUNNEL”
}
else
{write-host “All protocols are disabled”}

#*************************************************************************************************