Hi<\/p>\n
I have a list of device names exported to an csv file.<\/p>\n
I need to import this csv to then query the data and export the objectid of these computers from azure.<\/p>\n
I am using the below and the error I am receiving is beneath<\/p>\n
Can anyone point me in the right direction?<\/p>\n
#create<\/span> a variable for import-csv<\/p>\n $test3 = import-csv -path “C:\\temp\\test3.xml”<\/p>\n #output<\/span> objectid<\/p>\n Get-MsolDevice -Name $test3.Name | Select-Object -Property ObjectID | Export-CSV -Path “C:\\temp\\test9.xml”<\/p>\n Get-MsolDevice : Cannot convert ‘System.Object<\/span>’ to the type ‘System.String’ required by<\/p>\n parameter ‘Name’. Specified method is not supported.<\/p>\n At line:1 char:22<\/p>\n Get-MsolDevice -Name $test3.Name | Select-Object -Property ObjectID | …<\/p>\n<\/li>\n CategoryInfo : InvalidArgument: ( n<\/p>\n n.GetDevice<\/p>","upvoteCount":6,"answerCount":6,"datePublished":"2019-10-29T19:49:53.000Z","author":{"@type":"Person","name":"danb67","url":"https://community.spiceworks.com/u/danb67"},"suggestedAnswer":[{"@type":"Answer","text":" Hi<\/p>\n I have a list of device names exported to an csv file.<\/p>\n I need to import this csv to then query the data and export the objectid of these computers from azure.<\/p>\n I am using the below and the error I am receiving is beneath<\/p>\n Can anyone point me in the right direction?<\/p>\n #create<\/span> a variable for import-csv<\/p>\n $test3 = import-csv -path “C:\\temp\\test3.xml”<\/p>\n #output<\/span> objectid<\/p>\n Get-MsolDevice -Name $test3.Name | Select-Object -Property ObjectID | Export-CSV -Path “C:\\temp\\test9.xml”<\/p>\n Get-MsolDevice : Cannot convert ‘System.Object<\/span>’ to the type ‘System.String’ required by<\/p>\n parameter ‘Name’. Specified method is not supported.<\/p>\n At line:1 char:22<\/p>\n Get-MsolDevice -Name $test3.Name | Select-Object -Property ObjectID | …<\/p>\n<\/li>\n CategoryInfo : InvalidArgument: ( n<\/p>\n n.GetDevice<\/p>","upvoteCount":6,"datePublished":"2019-10-29T19:49:54.000Z","url":"https://community.spiceworks.com/t/exporting-objectid/736832/1","author":{"@type":"Person","name":"danb67","url":"https://community.spiceworks.com/u/danb67"}},{"@type":"Answer","text":" If $test3 contains more than one object, you will need to send them to Get-MsolDevice one at a time.<\/p>\n Also, your filename extensions are wonky. You should use .csv instead of .xml in this case.<\/p>\n Just to keep things clean.<\/p>","upvoteCount":1,"datePublished":"2019-10-29T20:09:22.000Z","url":"https://community.spiceworks.com/t/exporting-objectid/736832/3","author":{"@type":"Person","name":"tulioarends","url":"https://community.spiceworks.com/u/tulioarends"}},{"@type":"Answer","text":" Hi<\/p>\n Thanks I tried this but received the below error<\/p>\n This just loops round for each device it searches for<\/p>\n Get-MsolDevice : Device Not Found I took everything out of the csv and left in one machine name that I know for sure is in azure.<\/p>\n The script produces a csv but it’s blank with no column headings<\/p>","upvoteCount":0,"datePublished":"2019-10-29T20:45:57.000Z","url":"https://community.spiceworks.com/t/exporting-objectid/736832/5","author":{"@type":"Person","name":"danb67","url":"https://community.spiceworks.com/u/danb67"}},{"@type":"Answer","text":" can you give us the first two lines your CSV please<\/p>\n e.g.<\/p>\n HEADER1,HEADER2<\/p>\n SERVER1,Info<\/p>","upvoteCount":1,"datePublished":"2019-10-30T03:47:36.000Z","url":"https://community.spiceworks.com/t/exporting-objectid/736832/6","author":{"@type":"Person","name":"britv8","url":"https://community.spiceworks.com/u/britv8"}}]}}
\n
\n<\/code><\/pre>\n<\/li>\n
[Get-MsolDevice], ParameterBindingExceptio<\/p>\n<\/li>\n<\/ul>\n
\n
\n
\n<\/code><\/pre>\n<\/li>\n
[Get-MsolDevice], ParameterBindingExceptio<\/p>\n<\/li>\n<\/ul>\n
\n
$test3 = import-csv -path \"C:\\temp\\test3.xml\"\n\n#output objectid\n$Results = ForEach ($device in $test3) {\n Get-MsolDevice -Name $device.Name | Select-Object -Property ObjectID \n}\n$Results | Export-CSV -Path \"C:\\temp\\test9.xml\" -NoTypeInformation\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2019-10-29T19:54:49.000Z","url":"https://community.spiceworks.com/t/exporting-objectid/736832/2","author":{"@type":"Person","name":"Evan7191","url":"https://community.spiceworks.com/u/Evan7191"}},{"@type":"Answer","text":"
\nAt line:2 char:5<\/p>\n\n
<\/code><\/pre>\n<\/li>\n
[Get-MsolDevice], MicrosoftOnlineExceptio
\nn<\/li>\n
\ntion,Microsoft.Online.Administration.Automation.GetDevice<\/li>\n<\/ul>","upvoteCount":0,"datePublished":"2019-10-29T20:33:06.000Z","url":"https://community.spiceworks.com/t/exporting-objectid/736832/4","author":{"@type":"Person","name":"danb67","url":"https://community.spiceworks.com/u/danb67"}},{"@type":"Answer","text":"