-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathUsers.Functions.ps1
43 lines (40 loc) · 2.11 KB
/
Users.Functions.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
using NameSpace Microsoft.Graph.PowerShell.Models
# MicrosoftGraphReminder is in Microsoft.Graph.Users.Functions.private.dll
function Get-GraphReminderView {
<#
.Synopsis
Returns a view of items with reminders set across all a users calendars.
#>
[cmdletbinding(DefaultParameterSetName="None")]
[outputType([Microsoft.Graph.PowerShell.Models.MicrosoftGraphReminder])]
param (
#UserID as a guid or User Principal name, whose calendar should be fetched If not specified defaults to "me"
[ArgumentCompleter([UPNCompleter])]
$User = $Global:GraphUser,
#Time zone to rennder event times. By default the time zone of the local machine will me use
$Timezone = $(tzutil.exe /g),
#Number of days of calendar to fetch from today
[int]$Days = 30 ,
#The number of events to fetch. Must be greater than zero, and capped at 1000
[ValidateRange(1,1000)]
[int]$Top
)
begin {
$webParams = @{ Method = 'Get'
ValueOnly = $true
AsType = ([Microsoft.Graph.PowerShell.Models.MicrosoftGraphReminder])
#MicrosoftGraphReminder uses strings where there should be dates. Types.ps1xml adds fields for true dates
}
if ($TimeZone) {$webParams['Headers'] = @{'Prefer' = "Outlook.timezone=""$TimeZone"""}}
}
process {
foreach ($u in $User) {
if ($u.ID) {$u=$u.ID}
#users.functions.yml refers to /users/$u/microsoft.graph.reminderView(StartDateTime='{0:yyyy-MM-ddTHH:mm:ss}',EndDateTime='{1:yyyy-MM-ddTHH:mm:ss}')
#https://docs.microsoft.com/en-us/graph/api/user-reminderview?view=graph-rest-1.0&tabs=http gives the syntax here i.e. without "microsoft.graph."
$uri = "$GraphUri/users/$u/reminderView(startDateTime='{0:yyyy-MM-ddTHH:mm:ss}',endDateTime='{1:yyyy-MM-ddTHH:mm:ss}')"
$webParams['uri'] = $uri -f [datetime]::Today, [datetime]::Today.AddDays($days)
Invoke-GraphRequest @webParams
}
}
}