Have a CSV of DeviceName from AzureAD, need ObjectId or DeviceID

This topic contains 2 replies, has 3 voices, and was last updated by  Jon 2 weeks, 2 days ago.

  • Author
    Posts
  • #97694

    Chris Bush
    Participant

    Hello all,
    I have a CSV of Device Names in Azure AD, I want to get a list of DeviceID or ObjectId for each of the names on the list.

    I have tried the following
    #
    $CHGList = Import-Csv -path C:\Users\username\desktop\CHGList.csv

    get-msoldevice -name $CHGList | Select-Object ObjectID | Export-CSV -Path "C:\Users\username\desktop\AzureDeviceID.csv"
    #

    I have tried piping over results and running it that way
    I have tried changing the Custom Object to a String
    I have tried

    #
    $CHGList = Import-Csv -path C:\Users\username\desktop\CHGList.csv
    $Modification = $null
    $Modification = $CHGList -join ","
    get-msoldevice -name $Modification | Select-Object ObjectID | Export-CSV -Path "C:\Users\username\desktop\AzureDeviceID.csv"
    #

    I've looked at trying to loop through the CSV file and it's making no sense.

    Can I get some help?

    Thanks all for your time.

  • #97697

    Joel Sallow
    Participant

    What does your CSV look like? Even if it's a single property, you need to reference that property when passing the values to other things. For example, if the column in the CSV was named "DeviceName", you would do:

    Get-MsolDevice -Name $CHGList.DeviceName | Select-Object -Property ObjectID | Export-CSV -Path "C:\Users\username\desktop\AzureDeviceID.csv"
  • #97747

    Jon
    Participant

    What results do you get when you do this?

    get-msoldevice -name $CHGList | Select-Object ObjectID 

    Have you tried this?

    $chglist | get-msoldevice | select objectid

You must be logged in to reply to this topic.