--- title: "Sample Commands and Scripts" slug: "sample-commands-and-scripts" updated: 2026-03-11T14:46:12Z published: 2026-03-11T14:46:12Z canonical: "support.nectarcorp.com/sample-commands-and-scripts" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.nectarcorp.com/llms.txt > Use this file to discover all available pages before exploring further. # Sample Commands and Scripts ## MS Teams Datacenter Meeting Connection Summary Outputs a list of MS Teams datacenter locations where users have been connecting to for meetings over the past week. ```powershell Get-NectarSession -TimePeriod LAST_WEEK -Modalities AUDIO -Platforms TEAMS -SessionTypes CONFERENCE_SESSION |    Select-Object CalleeExtCity, CalleeExtCountry |    Group-Object calleeExtCity, calleeExtCountry |    Select-Object Count, Name | Sort-Object Count -Descending ``` ## Conference List with Participant Names Outputs a list of conferences from the last week with a list of participant names to a CSV file. ```powershell Get-NectarSession -TimePeriod LAST_WEEK -SessionTypes CONFERENCE |    Select-Object CallerPlatform, StartDate, confOrganizerorSpace,    @{Name='Duration(min)';Expression={[int]($_.Duration/60)}}, Participants, Modality,    @{Name='Participant Names';Expression={(Get-NectarConferenceParticipants -ConferenceID $_.id -Platform $_.CallerPlatform[0]).UserDisplayName | %{$ParticipantNames += ($(if($ParticipantNames){"; "}) + $_)}; $ParticipantNames}} |    Export-Csv ConfList.csv -NoTypeInformation ``` ## Call Volume Statistics by Location Outputs a list of locations and the total volume and total/min/max/average time spent on calls for a given timeframe. Outputs data to CSV files. ```powershell $RawData = Get-NectarSession -TimePeriod LAST_MONTH -SessionTypes PEER2PEER,PEER2PEER_MULTIMEDIA,PSTN | Select-Object CallerLocation, CalleeLocation, Duration $RawData | Show-GroupAndStats -GroupBy callerLocation -SumBy duration -ShowSumByAsTimeFormat | Export-Csv CallerStatsByLocation.csv -NoTypeInformation $RawData | Show-GroupAndStats -GroupBy calleeLocation -SumBy duration -ShowSumByAsTimeFormat | Export-Csv CalleeStatsByLocation.csv -NoTypeInformation ``` ## **Call Volume Statistics by Location Pairs** Outputs a list of location pairs and the total volume and total/min/max/average time spent on calls between location pairs for a given timeframe. Outputs data to CSV file. ```powershell $RawData = Get-NectarSession -TimePeriod LAST_MONTH -SessionTypes PEER2PEER,PEER2PEER_MULTIMEDIA,PSTN | Select-Object CallerLocation, CalleeLocation, Duration Show-GroupAndStats -InputObject $RawData -GroupBy callerLocation,calleeLocation -SumBy duration -ShowSumByAsTimeFormat | Format-Table ``` ## Daily Call Count Outputs a daily count of P2P, PSTN or CONFERENCE sessions for the previous week. ```powershell For ($x = 0; $x -gt -7; $x--) {    $DateFrom = (([DateTime](Get-Date).AddDays($x-1).ToString("yyyy-MM-dd")).ToUniversalTime()).ToString("yyyy-MM-dd hh:mm:ss");    $DateTo = ((([DateTime](Get-Date).AddDays($x).ToString("yyyy-MM-dd")).ToUniversalTime()).AddSeconds(-1)).ToString("yyyy-MM-dd hh:mm:ss");    Get-NectarModalityQualitySummary -Modality AUDIO -SessionTypes PSTN -TimePeriod CUSTOM -TimePeriodFrom $DateFrom -TimePeriodTo $DateTo | Select-Object @{Name='Date';Expression={(Get-Date).AddDays($x-1).ToString("yyyy-MM-dd")}}, @{Name='CallCount';Expression={[math]::Round($_.NUMBER_OF_STREAMS)/2}} } ``` ## Call Metric Averages by Location Outputs a summary of standard call quality metric averages (jitter, packet loss, roundtrip time) for the previous week grouped by location. ```powershell $LocationList = Get-NectarLocation | Select-Object NetworkName -Unique $LocationQualitySummary = @() ForEach ($Location in $LocationList) { $LocData = Get-NectarModalityQualitySummary -TimePeriod LAST_WEEK -Modality AUDIO -Locations $Location.networkName -SessionTypes 'PEER2PEER' | Select-Object LocationName, * -ExcludeProperty *_TREND $LocData.LocationName = $Location.networkName $LocationQualitySummary += $LocData } Return $LocationQualitySummary | Where {$_.NUMBER_OF_STREAMS -gt 0} | FT ``` ```powershell # FOR AVAYA/CISCO quality data only $LocationList = Get-NectarLocation | Select-Object NetworkName -Unique $LocationQualitySummary = @() ForEach ($Location in $LocationList) { $LocData = Get-NectarQualitySummary -TimePeriod LAST_DAY -Locations $Location.networkName | Select-Object LocationName, * -ExcludeProperty *_TREND, NUMBER_OF_STREAMS $LocData.LocationName = $Location.networkName $LocationQualitySummary += $LocData } Return $LocationQualitySummary | Where {$_.TOTAL_GOOD -ne $NULL} | FT ``` ## Call Metric Averages by Location and User Outputs a summary of standard call quality metric averages (jitter, packet loss, roundtrip time) for the previous day grouped by location and user. Places results in a CSV file called UserQualitySummary.csv as well as screen. ```powershell # Set the time period to pull call data. Select one of 'LAST_HOUR', 'LAST_DAY', 'LAST_WEEK', or 'LAST_MONTH' $TimePeriod = 'LAST_DAY' # Pull the list of locations $LocationList = Get-NectarLocation | Select-Object NetworkName -Unique # Remove any existing UserQualitySummary.csv file Remove-Item UserQualitySummary.csv -Force ForEach ($Location in $LocationList) {    # Get a list of users who made/received calls over the selected time period Write-Host "Working on $($Location.NetworkName)" $FromUserList = Get-NectarSession -CallerLocations $Location.NetworkName -TimePeriod $TimePeriod -Modalities AUDIO -SessionTypes 'PEER2PEER' | Select-Object from | Where {$_.from -ne 'unknown'} $ToUserList = Get-NectarSession -CalleeLocations $Location.NetworkName -TimePeriod $TimePeriod -Modalities AUDIO -SessionTypes 'PEER2PEER' | Select-Object to | Where {$_.to -ne 'unknown'} $UserList = ($FromUserList.From + $ToUserList.To) | Sort-Object -Unique Write-Host "$($Location.NetworkName) has $($UserList.Count) users"     $UserQualitySummary = @()     ForEach ($User in $UserList) { Write-Host "Working on $User" $UserData = Get-NectarModalityQualitySummary -TimePeriod $TimePeriod -Users $User -Modality AUDIO -SessionTypes PEER2PEER -ErrorAction SilentlyContinue | Select-Object User, Location, * -ExcludeProperty *_TREND If ($UserData) { $UserData.User = $User $UserData.Location = $Location.NetworkName $UserQualitySummary += $UserData } } $UserQualitySummary | Where {$_.NUMBER_OF_STREAMS -gt 0} | Export-Csv UserQualitySummary.csv -NoTypeInformation -Append } Return $UserQualitySummary | Where {$_.NUMBER_OF_STREAMS -gt 0} | FT ``` ```powershell # FOR AVAYA/CISCO quality data only # Set the time period to pull call data. Select one of 'LAST_HOUR', 'LAST_DAY', 'LAST_WEEK', or 'LAST_MONTH' $TimePeriod = 'LAST_DAY' # Pull the list of locations $LocationList = Get-NectarLocation | Select-Object NetworkName -Unique # Remove any existing UserQualitySummary.csv file Remove-Item UserQualitySummary.csv -Force ForEach ($Location in $LocationList) {    # Get a list of users who made/received calls over the selected time period Write-Host "Working on $($Location.NetworkName)" $FromUserList = Get-NectarSession -CallerLocations $Location.NetworkName -TimePeriod $TimePeriod -ShowQualityDetails | Select-Object from | Where {$_.from -ne 'unknown'} $ToUserList = Get-NectarSession -CalleeLocations $Location.NetworkName -TimePeriod $TimePeriod -ShowQualityDetails | Select-Object to | Where {$_.to -ne 'unknown'} $UserList = ($FromUserList.From + $ToUserList.To) | Sort-Object -Unique Write-Host "$($Location.NetworkName) has $($UserList.Count) users"     $UserQualitySummary = @()     ForEach ($User in $UserList) { Write-Host "Working on $User" $UserData = Get-NectarQualitySummary -TimePeriod $TimePeriod -Users $User -ErrorAction SilentlyContinue | Select-Object User, Location, * -ExcludeProperty *_TREND If ($UserData) { $UserData.User = $User $UserData.Location = $Location.NetworkName $UserQualitySummary += $UserData } } $UserQualitySummary | Where {$_.NUMBER_OF_STREAMS -gt 0} | Export-Csv UserQualitySummary.csv -NoTypeInformation -Append } Return $UserQualitySummary | Where {$_.NUMBER_OF_STREAMS -gt 0} | FT ``` ## List of IP Address Ranges not Associated with a Nectar Location Creates a list of IP Address ranges (assumed to be /24) that aren’t associated with a Nectar Location along with the volume and average NectarScore. ```powershell $CallList = Get-NectarSession -SessionTypes CONFERENCE_SESSION,PEER2PEER,PSTN -DurationFrom 1 -NectarScore 1-100 -TimePeriod LAST_WEEK $IPList = [System.Collections.ArrayList]@() $IPList += $CallList | Where-Object {$NULL -eq $_.CallerLocation -And $NULL -ne $_.callerIpAddress -And $_.CallerIPAddress.Length -le 19} | Select-Object @{Name='IPAddress';Expression={$_.callerIPAddress -Replace '^(\d+\.\d+\.\d+)\.\d+/\d+$', '$1.0'}}, NectarScore $IPList += $CallList | Where-Object {$NULL -eq $_.CalleeLocation -And $NULL -ne $_.calleeIpAddress -And $_.CalleeIPAddress.Length -le 19} | Select-Object @{Name='IPAddress';Expression={$_.calleeIPAddress -Replace '^(\d+\.\d+\.\d+)\.\d+/\d+$', '$1.0'}}, NectarScore $GroupedData = $IPList | Group-Object IPAddress | Sort-Object Count -Descending $Result = $GroupedData | ForEach-Object {    $AverageScore = ($_.Group.NectarScore | Measure-Object -Average).Average    [PSCustomObject]@{        IPAddress = $_.Name        Count = $_.Count        AvgNectarScore = $AverageScore    } } Return $Result ``` ## Poor Call List with Reasons Creates a CSV file of all poor audio calls for the previous day along with the metrics that made each call poor. Works for any platform, but this example focuses on Teams. This may take a long time to run, depending on the volume of poor calls. ```powershell $SessionList = @() $SessionParams = @{    TimePeriod = 'LAST_DAY'    Platforms = 'TEAMS'    Modalities = 'AUDIO'    SessionQualities = 'POOR_0_25'    SessionTypes = 'CONFERENCE_SESSION','PEER2PEER','PSTN' } $BadSessions = Get-NectarSession @SessionParams | Select-Object SessionID, startDate, duration, from, to, CallerLocation, CalleeLocation, callerDeviceVersion, CalleeDeviceVersion, CallerPlatform, CalleePlatform, Servers, CallerBadReason, CalleeBadReason ForEach ($Session in $BadSessions) { $BadDetails = Get-NectarSessionAlerts -SessionID $Session.SessionID -Platform $Session.CallerPlatform |  Where {$_.AlertLevel -eq 'CRITICAL'} $BadCallerStr=$NULL; $BadDetails | Where {$_.User -eq 'Caller'} | %{$BadCallerStr += ($(If($BadCallerStr){', '}) + ($_.Parameter -Replace('^\w+(Average|Caller)','')) + ':' + $_.Value)} $BadCalleeStr=$NULL; $BadDetails | Where {$_.User -eq 'Callee'} | %{$BadCalleeStr += ($(If($BadCalleeStr){', '}) + ($_.Parameter -Replace('^\w+(Average|Callee)','')) + ':' + $_.Value)} $Session.CallerBadReason = $BadCallerStr $Session.CalleeBadReason = $BadCalleeStr $SessionList += $Session } $SessionList | Export-Csv BadCallList.csv -NoTypeInformation ``` ## User Feedback Detail Report Creates a CSV file of the previous week's user feedback ratings/comments for MS Teams. Excludes feedback from 'External User'. ```powershell Get-NectarSession -TimePeriod LAST_WEEK -Modalities AUDIO -FeedbackRating EXCELLENT,GOOD,FAIR,POOR,BAD -SessionTypes CONFERENCE_SESSION,PEER2PEER,PEER2PEER_MULTIMEDIA,PSTN -Platforms TEAMS |   Where-Object {-not (($_.From -eq 'External User' -And $_.callerRating -ne $NULL) -or ($_.To -eq 'External User' -And $_.calleeRating -ne $NULL))} -PipelineVariable SummaryInfo |   Get-NectarSessionDetails |       Select-Object @{n='StartTime';e={$SummaryInfo.StartDate}}, @{n='Duration';e={[math]::Round($SummaryInfo.Duration/60,2)}}, Caller,Callee,*CallerFeedback*,*CalleeFeedback* | Export-Csv WeeklyTeamsUserFeedback.csv -NoTypeInformation ``` ## User Feedback Summary Report Creates a CSV file that will create a pivot table summarizing the user feedback ratings for a given timeframe grouped by day and rating. ```powershell # Pull down the full list of sessions with feedback $Params = @{    TimePeriod = 'LAST_WEEK'    Platforms = 'TEAMS'    Modalities = 'AUDIO' FeedbackRating = 'EXCELLENT','GOOD','FAIR','POOR','BAD'    SessionTypes = 'CONFERENCE_SESSION','PEER2PEER','PEER2PEER_MULTIMEDIA','PSTN' } $FullFeedbackList = Get-NectarSession @Params | Where-Object {-not (($_.From -eq 'External User' -And $_.callerRating -ne $NULL) -or ($_.To -eq 'External User' -And $_.calleeRating -ne $NULL))} | Select-Object StartDate,CallerRating,CalleeRating # Create a flat list of ratings and date/times. $FeedbackList = New-Object -TypeName "System.Collections.ArrayList" ForEach ($Entry in $FullFeedbackList) { If ($Entry.CallerRating -ne $NULL) { $FeedbackList.Add([PSCustomObject]@{StartDate=([datetime]$Entry.StartDate).ToShortDateString();Rating=$Entry.CallerRating}) | Out-Null } If ($Entry.CalleeRating -ne $NULL) { $FeedbackList.Add([PSCustomObject]@{StartDate=([datetime]$Entry.StartDate).ToShortDateString();Rating=$Entry.CalleeRating}) | Out-Null } } # Group the data for the pivot table $FeedbackGroupByDate = $FeedbackList | Group-Object StartDate $FeedbackGroupByRating = $FeedbackList | Group-Object Rating # Create the main pivot table. Each date is a row, and each feedback rating value is a column $PivotData = ForEach ($Date in $FeedbackGroupByDate) { $Props = @( @{ Name = 'Date' ; Expression = { $Date.Group | Select-Object -ExpandProperty StartDate -Unique }}        ForEach ($Rating in 'EXCELLENT','GOOD','FAIR','POOR','BAD') {            @{ Name = $Rating ; Expression = { ($Date.Group | Where-Object Rating -eq $Rating | Select-Object -ExpandProperty Rating | Measure-Object).Count }.GetNewClosure()} } @{ Name = 'Total' ; Expression = { ($Date.Group | Measure-Object).Count }} )    $Date | Select-Object $props } # Add a total row at the bottom $Props = @( @{ Name = 'Date' ; Expression = {'TOTAL'} } ForEach ($Rating in 'EXCELLENT','GOOD','FAIR','POOR','BAD') { @{ Name = $Rating ; Expression = { ($FeedbackGroupByRating | Where-Object Name -eq $Rating).Count }.GetNewClosure()} } @{ Name = 'Total' ; Expression =  { ($FeedbackGroupByRating | Measure-Object Count -Sum).Sum} } ) $PivotData += $FeedbackGroupByRating | Select-object $Props -Unique # Export to CSV $PivotData | Export-Csv FeedbackRatingSummary.csv -NoTypeInformation ``` ## Create Analytics Report by Corporate Location Creates an Analytics report that shows a chart with last week’s call volume and quality for each location. Schedules the report to run every week and email it to multiple users. ```powershell $ReportName = 'Weekly Volume and Quality Report - By Corp Location' $ReportDesc = 'Shows last week''s session volume and quality for all corporate locations' $LocationList = Get-NectarLocation | Select-Object networkName, siteName -Unique $SiteList = $LocationList | Select-Object SiteName -Unique | Where-Object {$_.SiteName -ne $NULL} | Sort-Object siteName Remove-Variable WidgetList -Scope Global -ErrorAction SilentlyContinue $WidgetParams = @{        WidgetDescription       = "Session Summary for $($Site.siteName)"        WidgetGroupVarName      = 'WidgetList'        TimePeriod              = 'LAST_WEEK'        SessionTypes            = 'PSTN','PEER2PEER','PEER2PEER_MULTIMEDIA' } ForEach ($Site in $SiteList) {        $LocationsInSite = $LocationList | Where-Object {$_.siteName -eq $Site.SiteName}        New-NectarReportWidget -WidgetType 'Call Details, Sessions' -Locations $LocationsInSite.networkName @WidgetParams        New-NectarReportWidget -WidgetType 'Call Details, Quality Audio' -Locations $LocationsInSite.networkName @WidgetParams } $ReportParams = @{        Name                    = $ReportName        Description             = $ReportDesc        WidgetList              = $WidgetList        Type                    = 'Tenant'        ScheduleMode            = 'WEEKLY'        SchedWeekday            = 'MONDAY'        SchedStartDate          = ((Get-Date).AddDays(7-((Get-Date).DayOfWeek.value__))).AddDays(1).ToString('yyyy-MM-dd')        SchedStartTime          = '09:00'        SchedNotifyMethod       = 'EMAIL'        SchedEmailSubject       = 'Weekly location call quality report'        SchedEmail              = 'tferguson@contoso.com', 'jblow@contoso.com' } New-NectarReport @ReportParams Remove-Variable WidgetList -Scope Global -ErrorAction SilentlyContinue ``` ## Create Analytics Report by Corporate Region Creates an Analytics report that shows a chart with last month’s call volume and quality for each corporate region. Schedules the report to run every month and email it to multiple users. ```powershell $ReportName = 'Monthly Volume and Quality Report - By Corp Region' $ReportDesc = 'Shows last month''s session volume and quality for all global regions' $LocationList = Get-NectarLocation | Select-Object siteName, region -Unique | Sort-Object siteName $RegionList = $LocationList | Select-Object region -Unique | Where-Object region -ne '' | Sort-Object region ForEach ($Region in $RegionList) {        $LocationsInRegion = $LocationList | Where-Object {$_.region -eq $Region.Region}        $WidgetParams = @{                WidgetDescription       = "Session Summary for $($Region.Region)"                WidgetGroupVarName      = 'WidgetList'                TimePeriod              = 'LAST_MONTH'                SessionTypes            = 'PSTN','PEER2PEER','PEER2PEER_MULTIMEDIA','CONFERENCE_SESSION'                Locations               = $LocationsInRegion.siteName        }        New-NectarReportWidget @WidgetParams -WidgetType 'Call Details, Sessions'        New-NectarReportWidget @WidgetParams -WidgetType 'Call Details, Quality Audio' } $ReportParams = @{        Name                    = $ReportName        Description             = $ReportDesc        WidgetList              = $WidgetList        Type                    = 'Tenant'        ScheduleMode            = 'MONTHLY'        SchedDayOfMonth         = '1'        SchedStartDate          = ((Get-Date).AddMonths(1).ToString('yyyy-MM-01'))        SchedStartTime          = '09:00'        SchedNotifyMethod       = 'EMAIL'        SchedEmailSubject       = 'Monthly regional call quality report'        SchedEmail              = 'tferguson@contoso.com', 'jblow@contoso.com' } New-NectarReport @ReportParams Get-NectarReport -SearchQuery $ReportName | Start-NectarReport Remove-Variable WidgetList -Scope Global ``` ## Add Orphan Devices to Nectar Room Attempts to add orphaned devices to a Nectar Room with the same name as the device. Works well with Teams devices/rooms ```powershell $DeviceList = Get-NectarDevice | Where-Object {$_.roomID -eq $NULL} $RoomList = Get-NectarRoom ForEach ($Device in $DeviceList) {     If ($RoomList | Where-Object {$_.name -eq $Device.deviceDisplayName}) {         Write-Host "Add to room $($Device.deviceDisplayName)"         Connect-NectarRoomDevice -RoomName $Device.deviceDisplayName -DeviceUnitedID $Device.deviceUnitedId -ErrorAction SilentlyContinue     } } ```