How to get azure AD device Object ID in Bulk

Gene 1 Reputation point
2022-04-07T00:21:58.953+00:00

Hello I have this script that i cant get to work? I am trying to load a CSV with a list of devices in Azure I need to extract the devices in an output csv file that has the displayname and the object ID
For some reason this script keeps omitting the Input csv file? Please help

connect-azuread
Import-csv c:\temp\devices.csv | %{get-azureADdevice -searchstring '$_devicename'} | Select Displayname, objectID | export-csv c:\temp\deviceswithObjectID.csv -notypeinformation

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2022-04-07T07:13:33.393+00:00

    You are missing a dot (.) in '$_devicename', and you can omit the quotes as well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.