Public/Get-NMMDevice.ps1
|
function Get-NMMDevice { <# .SYNOPSIS Get Intune managed devices for an account. .DESCRIPTION Retrieves Intune managed devices from the NMM API. This is a v1-beta endpoint. .PARAMETER AccountId The NMM account ID to query devices for. .PARAMETER DeviceId Optional. The ID of a specific device to retrieve. .EXAMPLE Get-NMMDevice -AccountId 123 .EXAMPLE Get-NMMDevice -AccountId 123 -DeviceId "device-guid" .EXAMPLE Get-NMMAccount | Get-NMMDevice #> [CmdletBinding()] param( [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] [Alias('id')] [int]$AccountId, [Parameter()] [string]$DeviceId ) process { if ($DeviceId) { Invoke-APIRequest -Method 'GET' -Endpoint "accounts/$AccountId/devices/$DeviceId" -ApiVersion 'v1-beta' } else { Invoke-APIRequest -Method 'GET' -Endpoint "accounts/$AccountId/devices" -ApiVersion 'v1-beta' } } } |