SOLVED

Azure AD join device list export

%3CLINGO-SUB%20id%3D%22lingo-sub-290550%22%20slang%3D%22en-US%22%3EAzure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-290550%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%2C%3C%2FP%3E%3CP%3ECan%20you%20please%20help%20me%20to%20export%20Azure%20AD%20join%20device%20list%20from%20azure%20portal%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20and%20Regards%2C%3C%2FP%3E%3CP%3EShubham%20Kumar%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-290550%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20AD%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-332314%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-332314%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20i%20try%20to%20export%20the%20list%20with%20registeredowners%20i%20am%20getting%26nbsp%3B%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3ESystem.Collections.Generic.List%601%5BSystem.String%5D%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3Ein%20the%20output.%20can%20you%20help%20me%20provide%20the%20correct%20expression%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-290672%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-290672%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Shubham%2C%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20can%20get%20a%20list%20of%20Azure%20AD%20joined%20devices%20through%20the%20Get-MsolDevice%20cmdlet%20in%20Powershell.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmsonline%2Fget-msoldevice%3Fview%3Dazureadps-1.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fmsonline%2Fget-msoldevice%3Fview%3Dazureadps-1.0%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20Get-MsolDevice%20-All%20-ReturnRegisteredOwners%20cmdlet%20will%20output%20a%20list%20of%20all%20devices%20and%20their%20owners%20which%20contain%20the%20output%20DeviceTrustType%20which%20is%20the%20device%20trust%20type.%20The%20value%20could%20be%20one%20of%20the%20following%3A%20Workplace%20Joined%2C%20AzureAD%20Joined%2C%20Domain%20Joined.%3CBR%20%2F%3E%3CBR%20%2F%3EAll%20you%20need%20to%20do%20is%20combine%20this%20with%20an%20export%20command%20such%20as%20%7C%20Export-Csv%20C%3A%5CTemp%5CLicensedUsers.csv%20and%20this%20should%20give%20you%20the%20list.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAFAIK%2C%20there%20isn't%20a%20way%20to%20do%20this%20through%20the%20portal%20currently.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%2C%20Chris%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-504342%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-504342%22%20slang%3D%22en-US%22%3E%3CP%3EHas%20there%20been%20any%20more%20answers%20on%20this%3F%26nbsp%3B%20I%20am%20getting%20the%20same%20issue%20when%20running%20the%20commands.%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F78358%22%20target%3D%22_blank%22%3E%40Praneeth%20Rajalingari%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F169605%22%20target%3D%22_blank%22%3E%40Christopher%20Hoard%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-512613%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-512613%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20also%20getting%20System.Collections.Generic.List%601%5BSystem.String%5D%20for%20the%20registered%20owners.%26nbsp%3B%20I've%20tried%20various%20methods%20to%20get%20the%20data%20to%20populate%2C%20however%2C%20since%20the%20username%20is%20behind%20%7B%7D%20it%20never%20seems%20to%20want%20to%20populate%20correctly.%26nbsp%3B%20Is%20the%20output%20an%20array%20of%20some%20sort%2C%20or%20just%20a%20generic%20text%20output%3F%26nbsp%3B%20I%20need%20this%20to%20more%20accurately%20control%20my%20inventory.%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F169605%22%20target%3D%22_blank%22%3E%40Christopher%20Hoard%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-525676%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-525676%22%20slang%3D%22en-US%22%3EHi%20guys%2C%3CBR%20%2F%3E%3CBR%20%2F%3EPersonally%2C%20I%20would%20recommend%20to%20raise%20a%20ticket%20for%20this%20if%20you%20are%20having%20issues%20with%20it.%20I%20have%20never%20experienced%20this%20issue%20so%20can't%20say%20what%20could%20be%20causing%20this.%3CBR%20%2F%3E%3CBR%20%2F%3EBest%2C%20Chris%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-693165%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-693165%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F330572%22%20target%3D%22_blank%22%3E%40jamesOnco360%3C%2FA%3EWondering%20if%20anyone%20has%20resolved%20the%20issue%20with%20returning%20the%26nbsp%3B%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3ESystem.Collections.Generic.List%601%5BSystem.String%5D%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3Bresult%20for%20Registered%20owners%20(instead%20of%20the%20UPN)%20when%20running%20the%20Azure%20AD%20Get-MSolDevice%20script%20and%20exporting%20to%20csv.%26nbsp%3B%20Thanks!%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F169605%22%20target%3D%22_blank%22%3E%40Christopher%20Hoard%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-693169%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-693169%22%20slang%3D%22en-US%22%3E%3CP%3ENot%20to%20my%20knowledge.%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F360585%22%20target%3D%22_blank%22%3E%40LD970%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-803424%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-803424%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F360585%22%20target%3D%22_blank%22%3E%40LD970%3C%2FA%3E%3C%2FP%3E%3CP%3EDoes%20this%20produce%20the%20desired%20result%3F%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EConnect-MsolService%0A%0A%24TStamp%20%3D%20%24(get-date%20-f%20MM-dd-yyyy_HH_mm_ss)%0A%0A%24Devices%20%3D%20Get-MsolDevice%20-All%20-ReturnRegisteredOwners%20-IncludeSystemManagedDevices%0A%24DeviceInfo%20%3D%20%40()%0A%0Aforeach%20(%24Device%20in%20%24Devices)%20%7B%0A%20%20%20%20%24DeviceInfo%20%2B%3D%20%5BPSCustomObject%5D%40%7B%0A%20%20%20%20%20%20%20%20%22DisplayName%22%20%3D%20%24Device.DisplayName%0A%20%20%20%20%20%20%20%20%22DeviceTrustType%22%20%3D%20%24Device.DeviceTrustType%0A%20%20%20%20%20%20%20%20%22DeviceTrustLevel%22%20%3D%20%24Device.DeviceTrustLevel%0A%20%20%20%20%20%20%20%20%22DeviceOS%22%20%3D%20%24Device.DeviceOsType%0A%20%20%20%20%20%20%20%20%22DeviceVersion%22%20%3D%20%24Device.DeviceOsVersion%0A%20%20%20%20%20%20%20%20%22RegisteredOwner%22%20%3D%20%24(%24Device.RegisteredOwners)%0A%20%20%20%20%20%20%20%20%22LastLogon%22%20%3D%20%24Device.ApproximateLastLogonTimestamp%0A%20%20%20%20%20%20%20%20%22LastDirSync%22%20%3D%20%24Device.LastDirSyncTime%0A%20%20%20%20%20%20%20%20%22DeviceID%22%20%3D%20%24Device.DeviceId%0A%20%20%20%20%20%20%20%20%22ObjectID%22%20%3D%20%24Device.ObjectId%0A%20%20%20%20%7D%0A%7D%0A%24DeviceInfo%20%7C%20Export-Csv%20-NoTypeInformation%20.%5C%22Device%20Info%20-%20%24TStamp.csv%22%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-833146%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-833146%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F391851%22%20target%3D%22_blank%22%3E%40kennedy_shane%3C%2FA%3E%26nbsp%3BI%20think%20it%20does%20but%20why%20do%20things%20in%2015%20lines%20when%20you%20could%20do%20it%20in%20one%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fhappyface_40x40.gif%22%20alt%3D%22%3Ahappyface%3A%22%20title%3D%22%3Ahappyface%3A%22%20%2F%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3EGet-MsolDevice%20-All%20-ReturnRegisteredOwners%20-IncludeSystemManagedDevices%20%7C%20Select-Object%20*%2C%40%7BName%3D'RegisteredOwnersToString'%3BExpression%20%3D%20%7B%24_.RegisteredOwners.Normalize()%7D%7D%20%7C%20Export-Csv%20devices.csv%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-951577%22%20slang%3D%22de-DE%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-951577%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F169605%22%20target%3D%22_blank%22%3E%40Christopher%20Hoard%3C%2FA%3E%20Very%20easy%2C%20very%20nice%2C%20thanks%20for%20the%20short%20Oneliner..%3C%2FP%3E%3CP%3EBut%20how%20to%20make%2C%20if%20I%20have%20to%20read%20more%20than%20thousand%20devices%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1313403%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1313403%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F391851%22%20target%3D%22_blank%22%3E%40kennedy_shane%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20can%20export%20all%20information%20using%20this%20cmd%20as%20well%3A%26nbsp%3BGet-MsolDevice%20-All%20%7C%20Export-CSV%20.%5CDevices.csv%3C%2FP%3E%3CP%3EHowever%2C%20I%20need%20the%20exact%20Particulars%20as%20highlighted%20in%20the%20below%20screenshot.%20Is%20it%20possible%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AADDevices.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F184800iE359E553618127A2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22AADDevices.png%22%20alt%3D%22AADDevices.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYour%20quick%20response%20will%20be%20highly%20appreciated.%20Thank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1417301%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20AD%20join%20device%20list%20export%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1417301%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20export%20this%20information%20from%20Azure%20too.%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F624829%22%20target%3D%22_blank%22%3E%40Global_Admin%3C%2FA%3E%26nbsp%3B.%26nbsp%3B%20get-msoldevice%20does%20not%20return%20the%20same%20values.%26nbsp%3B%20Is%20'domain%20joined'%20equivalent%20to%20Hybrid%20Azure%20AD%20joined%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMike%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi all,

Can you please help me to export Azure AD join device list from azure portal?

 

 

Thanks and Regards,

Shubham Kumar

 

14 Replies
best response confirmed by Shubham kumar (Occasional Contributor)
Solution

Hi Shubham,

You can get a list of Azure AD joined devices through the Get-MsolDevice cmdlet in Powershell.

https://docs.microsoft.com/en-us/powershell/module/msonline/get-msoldevice?view=azureadps-1.0

The Get-MsolDevice -All -ReturnRegisteredOwners cmdlet will output a list of all devices and their owners which contain the output DeviceTrustType which is the device trust type. The value could be one of the following: Workplace Joined, AzureAD Joined, Domain Joined.

All you need to do is combine this with an export command such as | Export-Csv C:\Temp\LicensedUsers.csv and this should give you the list.

 

AFAIK, there isn't a way to do this through the portal currently.

 

Best, Chris

When i try to export the list with registeredowners i am getting 

System.Collections.Generic.List`1[System.String]

in the output. can you help me provide the correct expression?

Has there been any more answers on this?  I am getting the same issue when running the commands. @Praneeth Rajalingari @Christopher Hoard 

I am also getting System.Collections.Generic.List`1[System.String] for the registered owners.  I've tried various methods to get the data to populate, however, since the username is behind {} it never seems to want to populate correctly.  Is the output an array of some sort, or just a generic text output?  I need this to more accurately control my inventory. @Christopher Hoard 

Hi guys,

Personally, I would recommend to raise a ticket for this if you are having issues with it. I have never experienced this issue so can't say what could be causing this.

Best, Chris

@jamesOnco360Wondering if anyone has resolved the issue with returning the 

System.Collections.Generic.List`1[System.String]

 result for Registered owners (instead of the UPN) when running the Azure AD Get-MSolDevice script and exporting to csv.  Thanks! @Christopher Hoard 

Not to my knowledge.@LD970 

@LD970

Does this produce the desired result?

Connect-MsolService

$TStamp = $(get-date -f MM-dd-yyyy_HH_mm_ss)

$Devices = Get-MsolDevice -All -ReturnRegisteredOwners -IncludeSystemManagedDevices
$DeviceInfo = @()

foreach ($Device in $Devices) {
    $DeviceInfo += [PSCustomObject]@{
        "DisplayName" = $Device.DisplayName
        "DeviceTrustType" = $Device.DeviceTrustType
        "DeviceTrustLevel" = $Device.DeviceTrustLevel
        "DeviceOS" = $Device.DeviceOsType
        "DeviceVersion" = $Device.DeviceOsVersion
        "RegisteredOwner" = $($Device.RegisteredOwners)
        "LastLogon" = $Device.ApproximateLastLogonTimestamp
        "LastDirSync" = $Device.LastDirSyncTime
        "DeviceID" = $Device.DeviceId
        "ObjectID" = $Device.ObjectId
    }
}
$DeviceInfo | Export-Csv -NoTypeInformation .\"Device Info - $TStamp.csv"

@kennedy_shane I think it does but why do things in 15 lines when you could do it in one :happyface: 

 

 

Get-MsolDevice -All -ReturnRegisteredOwners -IncludeSystemManagedDevices | Select-Object *,@{Name='RegisteredOwnersToString';Expression = {$_.RegisteredOwners.Normalize()}} | Export-Csv devices.csv

 

@Christopher HoardVery easy, very nice, thanks for the short Oneliner..

But how to make, if i have to read more than thousand devices?

@kennedy_shane 

 

We can export all information using this cmd as well: Get-MsolDevice -All | Export-CSV .\Devices.csv

However, I need the exact Particulars as highlighted in the below screenshot. Is it possible?

AADDevices.png

 

Your quick response will be highly appreciated. Thank you

I'm trying to export this information from Azure too.  @Global_Admin .  get-msoldevice does not return the same values.  Is 'domain joined' equivalent to Hybrid Azure AD joined?

 

Mike

@Joshua Bines Thanks for this code. I was able to get an export of all of my devices with RegisteredOwnersToString. Any idea how to import this and and filter it even further? Ultimately I want to find all Workplace Joined devices that aren't owned by a particular account (DEM account) and remove them from Azure. My first step is to just filter out those devices.

 

I've tried importing the csv I exported with your code:

 

$Device = Import-Csv C:\temp\12345.csv
$Device | ForEach-Object {Get-MsolDevice -all | Where-Object {$Device.DeviceTrustType -eq "Workplace Joined" -and ($Device.RegisteredOwnersToString -eq "account.name@domain.com")}}| Export-CSV -path c:\temp\filtered.csv

I've got a loop that keeps growing the filtered.csv file and it's not filtering out anything. 

 

I'm a Powershell novice so I'm trying to apply PS commands I've used in the past for other things to my current needs. 

 

Thanks for any help.

@delvalboyboy I'm glad it helped. If you have the export with the data you need I don't think you need to pull the same data again. I think should work and will be much faster. 

 

$Device = Import-Csv -Path "devicestest.csv"
$Device | ?{($_.DeviceTrustType -eq "Workplace Joined") -and ($_.RegisteredOwnersString -eq "User@consto.com")}

 

Or if your not up for PS... opening the CSV with excel and using the filter option could work just as well if the csv has all the data you require. Good luck! J

 

www.000webhost.com