Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GraphEssentials.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Description = 'GraphEssentials is a PowerShell module that helps with Office 365 / Azure AD using mostly Graph'
FunctionsToExport = @('Disable-MyDevice', 'Get-MgToken', 'Get-MyApp', 'Get-MyAppCredentials', 'Get-MyConditionalAccess', 'Get-MyDefenderDeploymentKey', 'Get-MyDefenderHealthIssues', 'Get-MyDefenderSecureScore', 'Get-MyDefenderSecureScoreProfile', 'Get-MyDefenderSensor', 'Get-MyDefenderSummary', 'Get-MyDevice', 'Get-MyDeviceIntune', 'Get-MyGuest', 'Get-MyLicense', 'Get-MyRole', 'Get-MyRoleHistory', 'Get-MyRoleUsers', 'Get-MyTeam', 'Get-MyTenantName', 'Get-MyUsageReports', 'Get-MyUser', 'Get-MyUserAuthentication', 'Invoke-MyDeviceRetire', 'Invoke-MyGraphEssentials', 'Invoke-MyGraphUsageReports', 'New-MyApp', 'New-MyAppCredentials', 'Register-FIDO2Key', 'Remove-MyAppCredentials', 'Remove-MyAutopilotDevice', 'Remove-MyDevice', 'Remove-MyDeviceIntuneRecord', 'Send-MyApp', 'Show-MyApp', 'Show-MyConditionalAccess', 'Show-MyDefender', 'Show-MyRole', 'Show-MyUserAuthentication')
GUID = '75ef812f-6d8e-4898-81bb-8029e0560ef3'
ModuleVersion = '0.0.58'
ModuleVersion = '0.0.59'
PowerShellVersion = '5.1'
PrivateData = @{
PSData = @{
Expand Down
8 changes: 7 additions & 1 deletion Public/Get-MyDevice.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
}

$AutopilotDevice = Find-GraphEssentialsAutopilotDevice -Lookup $AutopilotLookup -AzureAdDeviceId $Device.DeviceId
$AutopilotLastContacted = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('LastContactedDateTime', 'lastContactedDateTime') } else { $null }
$AutopilotLastContactedDays = if ($AutopilotLastContacted) { [math]::Floor((New-TimeSpan -Start $AutopilotLastContacted -End $Today).TotalDays) } else { $null }

[PSCustomObject] @{
Name = $Device.DisplayName
Expand Down Expand Up @@ -142,10 +144,14 @@
AutopilotInventoryLoaded = if ($IncludeAutopilotInventory) { [bool] $AutopilotLookup.InventoryLoaded } else { $false }
AutopilotOnboarded = if ($IncludeAutopilotInventory -and $AutopilotLookup.InventoryLoaded) { [bool] $AutopilotDevice } else { $null }
AutopilotDeviceId = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('Id', 'id') } else { $null }
AutopilotManagedDeviceId = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('ManagedDeviceId', 'managedDeviceId') } else { $null }
AutopilotAzureAdDeviceId = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('AzureAdDeviceId', 'azureAdDeviceId', 'AzureActiveDirectoryDeviceId', 'azureActiveDirectoryDeviceId') } else { $null }
AutopilotResourceName = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('ResourceName', 'resourceName', 'DisplayName', 'displayName') } else { $null }
AutopilotGroupTag = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('GroupTag', 'groupTag') } else { $null }
AutopilotSerialNumber = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('SerialNumber', 'serialNumber') } else { $null }
AutopilotEnrollmentState = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('EnrollmentState', 'enrollmentState') } else { $null }
AutopilotLastContacted = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('LastContactedDateTime', 'lastContactedDateTime') } else { $null }
AutopilotLastContacted = $AutopilotLastContacted
AutopilotLastContactedDays = $AutopilotLastContactedDays
AutopilotUserPrincipalName = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('UserPrincipalName', 'userPrincipalName') } else { $null }
}
}
Expand Down
8 changes: 7 additions & 1 deletion Public/Get-MyDeviceIntune.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
}

$AutopilotDevice = Find-GraphEssentialsAutopilotDevice -Lookup $AutopilotLookup -ManagedDeviceId $DeviceI.Id -AzureAdDeviceId $DeviceI.AzureAdDeviceId -SerialNumber $DeviceI.SerialNumber
$AutopilotLastContacted = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('LastContactedDateTime', 'lastContactedDateTime') } else { $null }
$AutopilotLastContactedDays = if ($AutopilotLastContacted) { [math]::Floor((New-TimeSpan -Start $AutopilotLastContacted -End $Today).TotalDays) } else { $null }

$DetailedInventoryLoaded = $false
$ActivationLockBypassCode = $null
Expand Down Expand Up @@ -225,10 +227,14 @@
AutopilotInventoryLoaded = if ($IncludeAutopilotInventory) { [bool] $AutopilotLookup.InventoryLoaded } else { $false }
AutopilotOnboarded = if ($IncludeAutopilotInventory -and $AutopilotLookup.InventoryLoaded) { [bool] $AutopilotDevice } else { $null }
AutopilotDeviceId = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('Id', 'id') } else { $null }
AutopilotManagedDeviceId = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('ManagedDeviceId', 'managedDeviceId') } else { $null }
AutopilotAzureAdDeviceId = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('AzureAdDeviceId', 'azureAdDeviceId', 'AzureActiveDirectoryDeviceId', 'azureActiveDirectoryDeviceId') } else { $null }
AutopilotResourceName = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('ResourceName', 'resourceName', 'DisplayName', 'displayName') } else { $null }
AutopilotGroupTag = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('GroupTag', 'groupTag') } else { $null }
AutopilotSerialNumber = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('SerialNumber', 'serialNumber') } else { $null }
AutopilotEnrollmentState = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('EnrollmentState', 'enrollmentState') } else { $null }
AutopilotLastContacted = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('LastContactedDateTime', 'lastContactedDateTime') } else { $null }
AutopilotLastContacted = $AutopilotLastContacted
AutopilotLastContactedDays = $AutopilotLastContactedDays
AutopilotUserPrincipalName = if ($AutopilotDevice) { Get-GraphEssentialsObjectProperty -InputObject $AutopilotDevice -Name @('UserPrincipalName', 'userPrincipalName') } else { $null }
#AdditionalProperties = $DeviceI.AdditionalProperties # : {}
}
Expand Down
6 changes: 6 additions & 0 deletions Tests/Get-MyDeviceIntune.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Describe 'Get-MyDeviceIntune' {
ManagedDeviceId = 'managed-1'
AzureActiveDirectoryDeviceId = 'device-1'
SerialNumber = 'serial-1'
ResourceName = 'serial-1'
GroupTag = 'pilot'
EnrollmentState = 'enrolled'
LastContactedDateTime = (Get-Date).AddDays(-5)
Expand All @@ -127,8 +128,13 @@ Describe 'Get-MyDeviceIntune' {
$devices[0].AutopilotInventoryLoaded | Should -BeTrue
$devices[0].AutopilotOnboarded | Should -BeTrue
$devices[0].AutopilotDeviceId | Should -Be 'autopilot-1'
$devices[0].AutopilotManagedDeviceId | Should -Be 'managed-1'
$devices[0].AutopilotAzureAdDeviceId | Should -Be 'device-1'
$devices[0].AutopilotResourceName | Should -Be 'serial-1'
$devices[0].AutopilotGroupTag | Should -Be 'pilot'
$devices[0].AutopilotSerialNumber | Should -Be 'serial-1'
$devices[0].AutopilotEnrollmentState | Should -Be 'enrolled'
$devices[0].AutopilotLastContactedDays | Should -BeGreaterOrEqual 4
}

It 'does not match Autopilot devices by duplicate serial number alone' {
Expand Down
Loading