Skip to content

Instantly share code, notes, and snippets.

@harrdou
Last active November 21, 2025 13:38
Show Gist options
  • Select an option

  • Save harrdou/ae16c2fe40a920c2385598c28c182dbd to your computer and use it in GitHub Desktop.

Select an option

Save harrdou/ae16c2fe40a920c2385598c28c182dbd to your computer and use it in GitHub Desktop.
Report non-migrated mobile users
# A script to report on those mobile users who have not yet
# migrated to EMDM-Cloud
# Select the input data file
Add-Type -AssemblyName System.Windows.Forms
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
Filter = 'CSV (Comma delimited) (*.csv)|*.csv'
Title = 'Open CSV file' }
$null = $FileBrowser.ShowDialog()
$dataFile = Import-Csv -Path $FileBrowser.FileName
# Connect to MS Graph
Connect-MgGraph -Scopes "Device.Read.All" -NoWelcome
# Locate migrated devices
$migratedDevices = Get-MgDevice -Filter "MdmAppId eq '0000000a-0000-0000-c000-000000000000' AND OperatingSystem in ('iOS', 'Android')"
$migratedUsers = New-Object System.Collections.Generic.HashSet[string]
foreach ($device in $migratedDevices) {
$owner = $device.DisplayName.Split(" ")[0]
$ignore = $migratedUsers.Add($owner.toLower())
}
Disconnect-MgGraph | Out-Null
# Enumerate non-migrated devices
$notMigrated = @()
foreach ($user in $dataFile) {
if (-not $migratedUsers.Contains($user."Email address".toLower())) {
$notMigrated += $user
}
}
# Export results
$FileBrowser = New-Object System.Windows.Forms.SaveFileDialog -Property @{
Filter = 'CSV (Comma delimited) (*.csv)|*.csv'
Title = 'Save results file'
FileName = 'Not-Migrated.csv' }
$null = $FileBrowser.ShowDialog()
$notMigrated | Export-Csv -Path $FileBrowser.FileName -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment