-
-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathSend-SlackChannelInvite.ps1
59 lines (48 loc) · 1.56 KB
/
Send-SlackChannelInvite.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function Send-SlackChannelInvite {
<#
.SYNOPSIS
Send a Slack channel invite
.DESCRIPTION
Send a Slack channel invite
.PARAMETER Token
Token to use for the Slack API
Default value is the value set by Set-PSSlackConfig
.PARAMETER Channel
ID of the Channel, private group, or IM channel to send file to.
.PARAMETER User
One or more user IDs to invite to the channel
.PARAMETER ForceVerbose
If specified, don't explicitly remove verbose output from Invoke-RestMethod
*** WARNING ***
This will expose your token in verbose output
.EXAMPLE
Send-SlackChannelInvite -Token $Token `
-Channel ABC123ID `
-User XYZ890ID
.FUNCTIONALITY
Slack
#>
param (
[string]$Token = $Script:PSSlack.Token,
[string]$Channel,
[string[]]$User,
[switch]$ForceVerbose = $Script:PSSlack.ForceVerbose
)
process
{
$body = @{}
switch ($psboundparameters.keys) {
'Channel' { $body.channel = $Channel }
'User' { $body.users = $User }
}
Write-Verbose "Send-SlackApi -Body $($body | Format-List | Out-String)"
$Params = @{
Method = 'conversations.invite'
Body = $Body
Token = $Token
ForceVerbose = $ForceVerbose
}
$response = Send-SlackApi @Params
$response
}
}