Microsoft Teams Enterprise Voice usuage Count [PSTN Enabled Count]

 Hello Everyone

Hope all are doing fine and well. Today am excited  to share the script to get the count of enterprise voice usage count country wise along with total sum. This may be helpful when you want to take the PSTN enabled report for management. 

The output file is HTML format and you may use send-mailmessage for emailing purpose


=========================================================================












=========================================================================

$Header = @"

<style>

table {font-family: "verdana";border-collapse: collapse;BORDER: 0.3px solid white;FONT-SIZE:  100%; padding: 1px;}

th {padding-top: 12px;padding-bottom: 12px;font-family: "calibri";text-align: left;background-color: #FF9F2C;color: white;BORDER: 0.3px solid white;FONT-SIZE:  100%; padding: 5px;}

td {white-space: nowrap;text-align: left;font-family: "calibri";BORDER: 0.3px  solid white;BORDER-COLOR: white;FONT-SIZE:  90%;padding: 5px; }

tr:nth-child(even){background-color: #EAEAEA} 

tr:nth-child(odd){background-color: #fafafa}

</style>

"@



$Attachment = "D:\output\MSTeamsEVCOUNT.htm"



######################################################

##START OF TOTAL COUNT

######################################################

$CONTHead =@"

<table>

                    <h3 style="font-family:verdana;">Total Enterprise Voice Count Summary</h3>

                   <tr>

                        <th>CountryCount</th>

                        <th>Name</th>

                                          </tr>


"@


$CONTBody = 

foreach ($SCONT in ((Get-Csonlineuser -Filter {EnterpriseVoiceEnabled -eq $true} | select Userprincipalname, Country | Group-Object -Property:Country | Measure-Object -Property Count -sum |  Select-Object Count, Sum -ErrorAction SilentlyContinue)))

             {

             "

                    <tr>

                        <td>$($SCONT.Count)</td>

                        <td>$($SCONT.Sum)</td>

                   </tr>

             "}

                          

$CONTEnd = 

@"

</table>

<br>

<br>

"@  


######################################################

##START OF EVCOUNT

######################################################

$EVCOUNT =@"

<table>

                    <h3 style="font-family:verdana;">MS Teams Enterprise Voice Count - Country Wise</h3>

                   <tr>

                        <th>Country</th>

                        <th>count</th>

                   </tr>


"@


$SCONBody = 

foreach ($SCON in (((Get-Csonlineuser -Filter {EnterpriseVoiceEnabled -eq $true}) | select Userprincipalname, Country | Group-Object -Property:Country | Select-Object Name, Count -ErrorAction SilentlyContinue)))

             {

             "

                    <tr>

                        <td>$($SCON.Name)</td>

                        <td>$($SCON.Count)</td>

                    </tr>

             "}

                          

$SCONEnd = 

@"

</table>

<br>

<br>

"@  


ConvertTo-HTML -Body "

$CONTHead $CONTBody $CONTEnd

$EVCOUNT $SCONBody $SCONEnd

" -Title "MS Teams EV Count Report" -Head $Header | Out-File $Attachment

=========================================================================

Comments

Post a Comment