-
Notifications
You must be signed in to change notification settings - Fork 17
/
New-RtrScript.psm1
64 lines (55 loc) · 1.57 KB
/
New-RtrScript.psm1
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
60
61
62
63
64
function New-RtrScript {
<#
.SYNOPSIS
Upload a new custom-script to use for the RTR 'runscript' command
.PARAMETER PATH
Full path to the script you wish to upload
.PARAMETER PERMISSION
Permission for the custom-script [default: private]
.PARAMETER DESCRIPTION
File description
.PARAMETER NAME
File name (if different than actual file name)
.PARAMETER COMMENT
The audit log comment
#>
[CmdletBinding()]
[OutputType([psobject])]
param(
[Parameter(Mandatory = $true)]
[string]
$Path,
[ValidateSet('private', 'group', 'public')]
[string]
$Permission = 'private',
[Parameter(Mandatory = $true)]
[string]
$Description,
[string]
$Name,
[string]
$Comment
)
process{
$Param = @{
Uri = '/real-time-response/entities/scripts/v1'
Method = 'post'
Header = @{
accept = 'application/json'
'content-type' = 'multipart/form-data'
}
Form = @{
file = (Get-Item -Path $Path)
description = $Description
permission_type = $Permission
}
}
switch ($PSBoundParameters.Keys) {
'Name' { $Param.Form['name'] = $Name }
'Comment' { $Param.Form['comments_for_audit_log'] = $Comment }
'Verbose' { $Param['Verbose'] = $true }
'Debug' { $Param['Debug'] = $true }
}
Invoke-CsAPI @Param
}
}