Had to perform an unplanned IIS Reset to fix an issue in production SharePoint Farm. But executing IISReset breaks ongoing user sessions and give “Service Unavailable” error message, isn’t it? Wouldn’t it be a good idea to find the No. of users currently connected with the SharePoint site and do the IISReset for a minimal impact? Sure!
How to find how many users connected with SharePoint sites? Use Performance Monitor!
- Go to Start >> Run >> Type “Perfmon”, to fire up Performance Monitor.
- Click on “Performance Monitor” , Right click “Add Counters” in Graph window
- Under the available Counters, Pick “Web Service” expand the node and select “Current Connections”
- Under “Instances of Selected object” You can either select “Total” or pick a particular web application
- Click on Add button to add the selected counter, and click “OK” button
Now the graph will show how many users connected to your SharePoint Site(s).
Please not, this gives only the no of user sessions currently ongoing. But not the one already completed (Doesn’t count the users already opened the site and left it idle!) There are possibilities that users may hit the SharePoint URL meanwhile and receive “Service Unavailable” message since IIS is reset!
PowerShell to get the current number of users connected:
We can also use PowerShell to get the number of users connected:
$servername = "Cres-SPWFE01" Get-Counter -Counter 'web service(_total)\current connections' -ComputerName $servername
This gets you the number of users connected with all websites on the server. Let’s get the number of users connected to a particular website:
$servername = "Cres-SPWFE01, Cres-SPWFE02, Cres-SPWFE03" $WebSiteName="Intranet Portal" #Web site name in IIS Get-Counter -Counter "web service($WebSiteName)\current connections" -ComputerName $ServerNames