Email Concurrent Connections to Web Front End – SharePoint 2013

If you need to find out how many concurrent user connections on to your WFE, you need to use the below script.  THe script uses Win32_PerfFormattedData_W3SVC_WebService performance Counter to give you exactly how many people are hitting a WFE and will send an email.  I have created a scheduled task that runs every hour from 9 ET to 4 ET.  
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
#The mail address of who will receive the backup exception message
$from = “”
#Send email function
function SendMail($subject, $body)
        #Getting SMTP server name and Outbound mail sender address
        $caWebApp = (Get-SPWebApplication -IncludeCentralAdministration) | ? { $_.IsAdministrationWebApplication -eq $true }
        $smtpServer = $caWebApp.OutboundMailServiceInstance.Server.Address
        $smtp = new-object Net.Mail.SmtpClient($smtpServer)

        #Creating a Mail object
        $message = New-Object System.Net.Mail.MailMessage
        $message.Subject = $subject
        $message.Body = $body
        $To =
        $message.From = $from
        #Creating SMTP server object
        #Sending email
        Write-Host "Email has been Sent!"
    catch [System.Exception]
        Write-Host "Mail Sending Error:" $_.Exception.Message -ForegroundColor Red

$String = ""
$String +="==============================================================================`n"
$String +="                 !!!!!    Connections Alert     !!!!!  `n"
$String +="==============================================================================`n"

#Change the value as per need
[system.int32]$Threshold = 100
[System.Boolean]$EmailNeed = $false
Write-Host "Server      : Connections"
Write-Host "============================"
$String +="Server            :     Connections Count`n"
$String +="==============================================================================`n"
$ServerCSV = ""

Get-WmiObject -Class Win32_PerfFormattedData_W3SVC_WebService -ComputerName Server1,Server2,Server3,Server4 | Where {$_.Name -eq "_Total"} | % `
    $ServerName = $_.__SERVER;
    $Connections = $_.CurrentConnections
    $String +="$ServerName : $Connections`n"
    Write-Host "$ServerName : $Connections" 

$String +="`n`n==============================================================================`n"
$String +="This is just an alert.  Please contact for more information.`n"

$Date = Get-Date
SendMail -subject "SharePoint : ! Connections !: Time: $Date" -body $String

Write-Host "Done.."
#Examples of how to find the required Counters
#Get-WmiObject -List | ? Name -like "*NetLogon*"
#Get-WmiObject -List | ? Name -like "*NetLogon*" | Select Name
#Get-WmiObject -List | ? Name -like "*NetLogon*" | Select -ExpandProperty Properties
#Get-WmiObject -Class Win32_PerfFormattedData_Counters_Netlogon -ComputerName Server1,Server2,Server3,Server4 | Where {$_.Name -eq "_Total"} | % {Write-Host $_.__SERVER;Write-Host $_.SemaphoreTimeouts}
Save the above script as GetConnect-FromServes.ps1

Scheduled Task XML

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="">
    <Principal id="Author">
  <Actions Context="Author">
      <Arguments>-ExecutionPolicy Bypass E:\Scripts\GetConnect-FromServes.ps1</Arguments>
Save the above XML as File and Open the Task in Task Schedule.  Change Credentials and Script Locations.

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s