Last active
November 21, 2025 13:38
-
-
Save harrdou/ae16c2fe40a920c2385598c28c182dbd to your computer and use it in GitHub Desktop.
Report non-migrated mobile users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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