How to find out the number of active sessions for a specific website hosted in IIS using PowerShell

I asked a question about knowing the session counter in IIS.

Get session counter from IIS for my hosted Asp.Net website

and I got the following powershell script

Write-host Getting performance counters ...

$perfCounterString = "\asp.net applications(__total__)\sessions active" 
$counter = get-counter -counter $perfCounterString 
$rawValue = $counter.CounterSamples[0].CookedValue 

write-host Session Count is $rawValue

      

Correct, this script gives an active session count for all websites hosted in IIS

I just wanted to know how to change this script so that it should only give an active session for a specific website.

+3


source to share


1 answer


$ServerName = 'IIs1'
$SiteName = 'default web site'

get-counter "\\$ServerName\web service($SiteName)\current connections"

      



+7


source







All Articles