-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvoke-MgShiftScheduleShare.ps1
39 lines (35 loc) · 1.14 KB
/
Invoke-MgShiftScheduleShare.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
function Invoke-MgShiftScheduleShare {
param (
#Id of the Team to get shifts from
[Parameter(Mandatory)][string]$teamId,
#Id of the user that the request is sent on the behalf of
[Parameter(Mandatory)][string]$actAsUID,
[Parameter(Mandatory)][bool]$notifyTeam,
[Parameter(Mandatory)][datetime]$startDateTime,
[Parameter(Mandatory)][datetime]$endDateTime
)
$ParameterExclusion = @("teamId","actAsUID")
$Body = $null
$PSBoundParameters.Keys.ForEach({
[string]$Key = $_
$Value = $PSBoundParameters.$key
if ($ParameterExclusion -contains $Key) {
return
}
$Body += @{
$Key = $Value
}
})
$Splat = @{
"Uri" = "https://graph.microsoft.com/v1.0/teams/$teamId/schedule/share"
"Method" = "POST"
"Headers" = @{
"Accept" = "application/json"
"Content-Type" = "application/json"
"Authorization" = "Bearer $(Get-MgAccessToken)"
"MS-APP-ACTS-AS" = $actAsUID
}
"Body" = ($Body | ConvertTo-Json)
}
Invoke-RestMethod @Splat
}