forked from mariuszwojcik/RabbitMQTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetItemsFromRabbitMQApi.ps1
43 lines (32 loc) · 1.33 KB
/
GetItemsFromRabbitMQApi.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
function GetItemsFromRabbitMQApi
{
[CmdletBinding(DefaultParameterSetName='login')]
Param
(
[parameter(Mandatory=$true, ParameterSetName='login', Position = 0)]
[string]$cn,
[parameter(Mandatory=$true, ParameterSetName='login', Position = 1)]
[string]$userName,
[parameter(Mandatory=$true, ParameterSetName='login', Position = 2)]
[string]$password,
[parameter(Mandatory=$true, ParameterSetName='login', Position = 3)]
[string]$fn,
[parameter(Mandatory=$true, ParameterSetName='cred', Position = 0)]
[string]$computerName,
[parameter(Mandatory=$true, ParameterSetName='cred', Position = 1)]
[PSCredential]$cred,
[parameter(Mandatory=$true, ParameterSetName='cred', Position = 2)]
[string]$function
)
Add-Type -AssemblyName System.Web
#Add-Type -AssemblyName System.Net
if ($PsCmdlet.ParameterSetName -eq "login")
{
$computerName = $cn
$cred = GetRabbitMqCredentials $userName $password
$function = $fn
}
$url = "http://$([System.Web.HttpUtility]::UrlEncode($computerName)):15672/api/$function"
Write-Verbose "Invoking REST API: $url"
return Invoke-RestMethod $url -Credential $cred -DisableKeepAlive -AllowEscapedDotsAndSlashes
}