Public/Support/VoiceConfig/Get-TeamsCP.ps1
# Module: Orbit.Teams # Function: VoiceConfig # Author: David Eberhardt # Updated: 01-APR-2021 # Status: Live function Get-TeamsCP { <# .SYNOPSIS Lists all Teams Calling Policies by Name .DESCRIPTION To quickly find Teams Calling Policies to assign, an Alias-Function to Get-CsTeamsCallingPolicy .PARAMETER Identity String. Name or part of the Teams Calling Policy. Can be omitted to list Names of all Policies (including "Global"). If provided without a '*' in the name, an exact match is sought. .EXAMPLE Get-TeamsCP Returns the Object for all Teams Calling Policies (including "Global") Behaviour like: Get-CsTeamsCallingPolicy, showing only a few Parameters .EXAMPLE Get-TeamsCP -Identity AllowCallingPreventTollBypass Returns the Object for the Teams Calling Policy "AllowCallingPreventTollBypass" (provided it exists). Behaviour like: Get-CsTeamsCallingPolicy -Identity "AllowCallingPreventTollBypass" .EXAMPLE Get-TeamsCP -Identity Allow* Lists Calling Policies with "Allow" in the Name Behaviour like: Get-CsTeamsCallingPolicy -Filter "*Allow*" .NOTES This script is indulging the lazy admin. It behaves like Get-CsTeamsCallingPolicy with a twist: If more than three results are found, a reduced set of Parameters are shown for better visibility: Get-CsTeamsCallingPolicy | Select-Object Identity, Description, BusyOnBusyEnabledType .INPUTS None System.String .OUTPUTS System.Object .COMPONENT SupportingFunction VoiceConfiguration .FUNCTIONALITY Queries Calling Policies by Name .LINK https://github.com/DEberhardt/Orbit/tree/main/docs/Orbit.Teams/Get-TeamsCP.md .LINK https://github.com/DEberhardt/Orbit/tree/main/docs/about/about_VoiceConfiguration.md .LINK https://github.com/DEberhardt/Orbit/tree/main/docs/about/about_Supporting_Functions.md .LINK https://github.com/DEberhardt/Orbit/tree/main/docs/ #> [CmdletBinding()] param ( [Parameter(Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName, HelpMessage = 'Name of the Calling Policy')] [string]$Identity ) begin { Show-OrbitFunctionStatus -Level Live Write-Verbose -Message "[BEGIN ] $($MyInvocation.MyCommand)" # Asserting MicrosoftTeams Connection if ( -not (Assert-MicrosoftTeamsConnection) ) { throw 'Connection to Microsoft Teams not established. Please validate connection' } } #begin process { Write-Verbose -Message "[PROCESS] $($MyInvocation.MyCommand)" if ($PSBoundParameters['Identity']) { Write-Verbose -Message "Finding Teams Calling Policy with Identity '$Identity'" if ($Identity -match [regex]::Escape('*')) { $Filtered = Get-CsTeamsCallingPolicy -Filter "*$Identity*" -ErrorAction $ErrorActionPreference } else { $Filtered = Get-CsTeamsCallingPolicy -Identity "$Identity" -ErrorAction $ErrorActionPreference } } else { Write-Verbose -Message 'Finding Teams Calling Policy Names' $Filtered = Get-CsTeamsCallingPolicy -ErrorAction $ErrorActionPreference # | Where-Object Identity -NE 'Global' } if ( $Filtered.Count -gt 3) { $Filtered = $Filtered | Select-Object Identity, Description, BusyOnBusyEnabledType #, AllowPrivateCalling } return $Filtered | Sort-Object Identity } #process end { Write-Verbose -Message "[END ] $($MyInvocation.MyCommand)" } #end } # Get-TeamsCP |