Public/Slack/Channel/Get-SlackChannel.ps1
|
function Get-SlackChannel { [CmdletBinding(DefaultParameterSetName = 'Collection')] param ( [Parameter(Mandatory=$true, ParameterSetName = 'Single')] [String]$Name ) process { switch ($PSCmdlet.ParameterSetName) { 'Single' { # Check if the channel exists $channel = $null Get-Channel -Name $Name | Where-Object { $_.Type -eq "Slack" } | ForEach-Object { $channel = $_ } If ( $null -eq $channel ) { throw "Channel $( $Name ) not found!" } break } 'Collection' { $channel = @( Get-NotificationChannels -Type "Slack" ) break } } #return $channel } } |