This SQL query is aimed to retrieve devices from MBAM Database.
/* Query to find machine name and their recovery keys */ Select mac.Name "Machine Name" , K.RecoveryKeyId "Recovery Key ID" , K.RecoveryKey "Recovery Key" FROM [MBAM Recovery and Hardware].RecoveryAndHardwareCore.Machines MAC JOIN [MBAM Recovery and Hardware].RecoveryAndHardwareCore.Machines_Volumes mv ON MAC.id = mv.machineid JOIN [MBAM Recovery and Hardware].RecoveryAndHardwareCore.Keys k ON mv.volumeId = k.VolumeID /* Query to find the duplicate volume IDs. If a volume ID shows up for multiple machines then it means that those machines have same volume GUIDs. The recovery information of these machines may get overwritten in the database.*/ Select mn.Name "Machine Name", MV.VolumeID "Volume ID" FROM RecoveryAndHardwareCore.Machines AS mn INNER JOIN RecoveryAndHardwareCore.Machines_Volumes AS mv ON mn.Id = mv.MachineId order by mv.VolumeId /* Query to list all the machines which have duplicate volume IDs. If a volume ID shows up for multiple machines then it means that those machines have same volume GUIDs. The recovery information of these machines may get overwritten in the database.*/ Select RecoveryAndHardwareCore.Machines.Name from RecoveryAndHardwareCore.Machines where RecoveryAndHardwareCore.Machines.Id in (SELECT RecoveryAndHardwareCore.Machines_Volumes.MachineId from RecoveryAndHardwareCore.Machines_Volumes where RecoveryAndHardwareCore.Machines_Volumes.VolumeId IN (select RecoveryAndHardwareCore.Machines_Volumes.VolumeId From RecoveryAndHardwareCore.Machines_Volumes GROUP BY VolumeId HAVING COUNT(RecoveryAndHardwareCore.Machines_Volumes.VolumeId) > 1)) /* done */