-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathGet-MSGraphIntuneUserDevice.ps1
More file actions
44 lines (33 loc) · 1.08 KB
/
Copy pathGet-MSGraphIntuneUserDevice.ps1
File metadata and controls
44 lines (33 loc) · 1.08 KB
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
Function Get-MSGraphIntuneUserDevice {
<#
.SYNOPSIS
This function is used to get an AAD User Devices from the Graph API REST interface
.DESCRIPTION
The function connects to the Graph API Interface and gets a users devices registered with Intune MDM
Created based on examples from https://github.com/microsoftgraph/powershell-intune-samples
.EXAMPLE
Get-MSGraphIntuneUserDevice -UserID $UserID
Returns all user devices registered in Intune MDM
.NOTES
NAME: Get-MSGraphIntuneUserDevice
#>
[cmdletbinding()]
param
(
[Parameter(Mandatory = $true, HelpMessage = "UserID (guid) for the user you want to take action on must be specified:")]
$UserID,
$AuthenticationToken
)
# Defining Variables
$graphApiVersion = "beta"
$Resource = "users/$UserID/managedDevices"
try {
$uri = "https://graph.microsoft.com/$graphApiVersion/$($Resource)"
Write-Verbose $uri
(Invoke-RestMethod -Uri $uri -Headers $AuthenticationToken -Method Get -ErrorAction Stop).Value
}
catch {
throw $_.Exception.Message
}
}