Author Posts

April 2, 2018 at 8:29 pm

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.

April 2, 2018 at 8:52 pm

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"

April 3, 2018 at 1:27 pm

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