Forum Discussion
Skipster311-1
Aug 27, 2021Iron Contributor
Compare two csv files
Hello I am trying to get an idea of devices that have not enrolled in Intune, but are accessing exchange online. I am using two .csv files. The intune file contains all devices that have enrolled...
- Aug 27, 2021
Skipster311-1 Give this a try. It'll output two files, one containing the devices that are only in the Intune file, and the other with devices that only exist in the Exchange file.
$Intune = Import-CSV .\intune.csv | Group-Object -AsHashTable -AsString -Property 'DeviceID' $Exchange = Import-CSV .\mobiledevicereport.csv | Group-Object -AsHashTable -AsString -Property 'DeviceID' $OnlyInIntune = @() $OnlyInExchange = @() ForEach ($Device in $Intune.Values) { if (!$Exchange[$Device.DeviceID]) { $OnlyInIntune += $Device } } ForEach ($Device in $Exchange.Values) { if (!$Intune[$Device.DeviceID]) { $OnlyInExchange += $Device } } $OnlyInIntune | Export-CSV -NoTypeInformation DevicesOnlyInIntune.csv $OnlyInExchange | Export-CSV -NoTypeInformation DevicesOnlyInExchange.csv
pvanberlo
Aug 27, 2021MCT
Skipster311-1 Give this a try. It'll output two files, one containing the devices that are only in the Intune file, and the other with devices that only exist in the Exchange file.
$Intune = Import-CSV .\intune.csv | Group-Object -AsHashTable -AsString -Property 'DeviceID'
$Exchange = Import-CSV .\mobiledevicereport.csv | Group-Object -AsHashTable -AsString -Property 'DeviceID'
$OnlyInIntune = @()
$OnlyInExchange = @()
ForEach ($Device in $Intune.Values) {
if (!$Exchange[$Device.DeviceID]) {
$OnlyInIntune += $Device
}
}
ForEach ($Device in $Exchange.Values) {
if (!$Intune[$Device.DeviceID]) {
$OnlyInExchange += $Device
}
}
$OnlyInIntune | Export-CSV -NoTypeInformation DevicesOnlyInIntune.csv
$OnlyInExchange | Export-CSV -NoTypeInformation DevicesOnlyInExchange.csv
- Skipster311-1Aug 27, 2021Iron ContributorWorked perfectly. Thank you again