-
Notifications
You must be signed in to change notification settings - Fork 219
/
ComplianceAPI_utils.ps1
38 lines (35 loc) · 1.19 KB
/
ComplianceAPI_utils.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
# This file contains utility functions for Compliance API
# Invokes request for the given compliance API call
# Aug 31st 2021
function Invoke-ComplianceAPIRequest
{
[cmdletbinding()]
Param(
[Parameter(Mandatory=$True)]
[String]$AccessToken,
[Parameter(Mandatory=$True)]
[String]$api,
[Parameter(Mandatory=$False)]
[String]$Method = "Get",
[Parameter(Mandatory=$False)]
[String]$Body = $null,
[Parameter(Mandatory=$False)]
[String]$ContentType = "application/json; charset=utf-8",
[Parameter(Mandatory=$False)]
[Hashtable]$Headers=@{}
)
Process
{
$url = "https://compliance.microsoft.com/api/$api"
$headers["Authorization"] = "Bearer $AccessToken"
# Invoke the command
if($Method -eq "Put" -or $Method -eq "Post")
{
Invoke-RestMethod -UseBasicParsing -Method $Method -Uri $url -Headers $Headers -WebSession $session -Body $body -ContentType $ContentType
}
else
{
Invoke-RestMethod -UseBasicParsing -Method $Method -Uri $url -Headers $Headers -WebSession $session -ContentType $ContentType
}
}
}