Report My CS Network Details, Bro.

Another useful tool in large enterprise environments is to match all your Lync/Skype CS Network subnets to the sites, regions and bandwidth policies in which they’re associated with into a single report.  This script creates a combined array with all applicable details which can be exported, sorted, filtered, graphed any which way your heart desires.

You should be clear just to save as a .ps1 and execute in any environment as no variables need to be individualized unless desired.  You will need PS5.0 with the ImportExcel module installed.

The below is an example of what it should look like.  Should you not have any bandwidth policy tied to a site/subnet it will result with “null”.

The guts:

# Script will output a combined spreadsheet to include all CS Network Subnets, Masks, Sites, Regions and Bandwidth Policies
# Created by Jeff McBride 12/27/2016
# This script utilizes Export-Excel which requires PowerShell 5.0. Export-CSV can be easily used instead, just swap the # on last lines.

$FileDate = (Get-Date).ToString('MM-dd-yyyy')

#Generate Lync Current network config Array
$CSSubnets = Get-CSNetworkSubnet | Select Identity, MaskBits, NetworkSiteID
$CSSites = Get-CSNetworkSite | Select Identity, NetworkSiteID, NetworkRegionID, BWPolicyProfileID
$CSBandPol = Get-CSNetworkBandwidthPolicyProfile | Select Identity, BWPolicyProfileID, BWPolicy

#Generate a combined array to make life easier
[System.Collections.ArrayList]$LyncDetailsArray = @()
$CSSubnetsCount = $CSSubnets.count
$i = 0
ForEach ($subnet in $CSSubnets) {
 $subsitetemp = $subnet.NetworkSiteID
 $SubSite = $CSSites | ? {$_.NetworkSiteID -eq $subsitetemp}
 $SubPolTemp = $SubSite.BWPolicyProfileID
 $SubPol = $CSBandPol | ? {$_.BWPolicyProfileID -eq $SubPolTemp}
 If ($SubPol -eq $null) {
 $BandwidthPolicy = "null"
 $BWAudio = "null"
 $BWAudioSession = "null"
 $BWVideo = "null"
 $BWVideoSession = "null"
 } Else {
 $BandwidthPolicy = $SubPol.BWPolicyProfileID
 $BWAudio = $SubPol.BWPolicy[0].BWLIMIT
 $BWAudioSession = $SubPol.BWPolicy[0].BWSessionLimit
 $BWVideo = $SubPol.BWPolicy[1].BWLIMIT
 $BWVideoSession = $SubPol.BWPolicy[1].BWSessionLimit
 $LyncDetails = New-Object PSObject
 $LyncDetails | Add-Member -NotePropertyName Identity -NotePropertyValue $subnet.Identity
 $LyncDetails | Add-Member -NotePropertyName MaskBits -NotePropertyValue $subnet.MaskBits
 $LyncDetails | Add-Member -NotePropertyName NetworkSiteID -NotePropertyValue $subnet.NetworkSiteID
 $LyncDetails | Add-Member -NotePropertyName NetworkRegionID -NotePropertyValue $SubSite.NetworkRegionID
 $LyncDetails | Add-Member -NotePropertyName BW_PolicyProfileID -NotePropertyValue $BandwidthPolicy
 $LyncDetails | Add-Member -NotePropertyName BW_Audio -NotePropertyValue $BWAudio
 $LyncDetails | Add-Member -NotePropertyName BW_AudioSession -NotePropertyValue $BWAudioSession
 $LyncDetails | Add-Member -NotePropertyName BW_Video -NotePropertyValue $BWVideo
 $LyncDetails | Add-Member -NotePropertyName BW_VideoSession -NotePropertyValue $BWVideoSession
 $LyncDetailsArray.Add($LyncDetails) > $null
 Write-Host "Gathering all current Lync details for" $subnet.Identity $subnet.NetworkSiteID
 Write-Host "$i out of $CSSubnetsCount"

#Export array to EXCEL or CSV
$LyncDetailsArray | Export-Excel (".\Lync-NetworkDetails-" + $FileDate + ".xlsx") -WorkSheet "LyncNetworkDetails"
#$LyncDetailsArray | Export-CSV -notypeinformation (".\Lync-NetworkDetails-" + $FileDate + ".csv")

Leave a Reply