Functions/Set-SlackChannel.ps1
<#
.SYNOPSIS This function sets properties of a Slack channel. .DESCRIPTION This function sets properties of a Slack channel. #> function Set-SlackChannel { [CmdletBinding(PositionalBinding=$false)] [OutputType([Bool])] param( # The authentication token for Slack [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String]$token, # The name of the channel to set [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String]$channelName, # The channel will be archived or not. # If not specified, the state will not be changed. [Parameter(Mandatory=$false)] [Nullable[boolean]]$archived = $null, # The new purpose of the channel [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [String]$purpose, # The new topic of the channel [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [String]$topic, # The new name of the channel [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [String]$newChannelName ) # Initialize the 'Set Channel' result $success = $true # Archive or unarchive the channel if ($archived) { $result = Archive-SlackChannel -Token $token -ChannelName $channelName # Set the 'Set Channel' result to false if $result is $false if (!$result) { $success = $false } } elseif ($false -eq $archived) { $result = Unarchive-SlackChannel -Token $token -ChannelName $channelName # Set the 'Set Channel' result to false if $result is $false if (!$result) { $success = $false } } # Set the purpose of the channel if ($purpose) { $result = Set-SlackChannelPurpose -Token $token -ChannelName $channelName -Purpose $purpose # Set the 'Set Channel' result to false if $result is $false if (!$result) { $success = $false } } # Set the topic of the channel if ($topic) { $result = Set-SlackChannelTopic -Token $token -ChannelName $channelName -Topic $topic # Set the 'Set Channel' result to false if $result is $false if (!$result) { $success = $false } } # Rename the channel if ($newChannelName) { $result = Rename-SlackChannel -Token $token -ChannelName $channelName -NewChannelName $newChannelName # Set the 'Set Channel' result to false if $result is $false if (!$result) { $success = $false } } # Return whether the update is successful return $success } |