# Trying to use PowerShell to get AutoPilot information from Intune

**URL:** <https://forums.powershell.org/t/trying-to-use-powershell-to-get-autopilot-information-from-intune/14691>\
**Category:** PowerShell Help\
**Created:** [July 21, 2020, 6:55am UTC](https://forums.powershell.org/t/trying-to-use-powershell-to-get-autopilot-information-from-intune/14691 "2020-07-21T06:55:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![smack2k](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@smack2k](https://forums.powershell.org/u/smack2k)\
**Post date:** [July 21, 2020, 6:55am UTC](https://forums.powershell.org/t/trying-to-use-powershell-to-get-autopilot-information-from-intune/14691/1 "2020-07-21T06:55:08Z")

</div>

Hello,

I am a moderate PowerShell user and am having some issues trying to get some device information from Azure AD by using devices set for Enrollment in Intune

There are device properties that can be used to setup Dynamic Groups in Azure AD / Intune. When setting up a group to pull machines using Purchase Order info, the query is  
\<p style=“margin: 0in; font-family: Calibri; font-size: 11.0pt;”\>(device.devicePhysicalIds -any \_ -eq “[PurchaseOrderId]:76222342342”)\</p\>  
I am trying to use this information somehow with PowerShell to pull a list of all machines with a particular purchase order and then add them to an AAD group I specify. The AAD groups are already created and are manual groups, so I cant use a new Dynamic Group to do this…

I have tried using Get-AzureADDevice with a -Filter but cant seem to get a query to work with the filter, and if the query works, I dont know if the properties are even usable.

Just not sure how I can use those query values in PowerShell to get the information I want, if I can at all…

Thanks for any assistance.

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [July 21, 2020, 7:01am UTC](https://forums.powershell.org/t/trying-to-use-powershell-to-get-autopilot-information-from-intune/14691/2 "2020-07-21T07:01:58Z")

</div>

Cam you share your code, what you have tried … 🙂

That “query” you give looks like and HTML Paragraph tag, I assume the parapraph contents define the query?

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [July 21, 2020, 7:41am UTC](https://forums.powershell.org/t/trying-to-use-powershell-to-get-autopilot-information-from-intune/14691/3 "2020-07-21T07:41:27Z")

</div>

Hi Brian,

You may try this, it worked for HWID.

```
Get-AzureADDevice -Filter "DevicePhysicalIds eq '[PurchaseOrderId]:76222342342'"
```

Here are some helpful links. It seems this command and module are limited.  
[https://www.michev.info/Blog/Post/1888/filtering-users-and-groups-with-the-azure-ad-graph-odata-syntax](https://www.michev.info/Blog/Post/1888/filtering-users-and-groups-with-the-azure-ad-graph-odata-syntax)

> **[Azure AD Graph API Supported Queries Filters and Paging Options](https://docs.microsoft.com/en-us/previous-versions/azure/ad/graph/howto/azure-ad-graph-api-supported-queries-filters-and-paging-options)**

---

<div class="post-metadata">

**Author:** ![smack2k](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@smack2k](https://forums.powershell.org/u/smack2k)\
**Post date:** [July 22, 2020, 2:37am UTC](https://forums.powershell.org/t/trying-to-use-powershell-to-get-autopilot-information-from-intune/14691/4 "2020-07-22T02:37:50Z")

</div>

My apologies for the paragraph tags, I clicked on the wrong link button…

I ended up finding the Windows AutoPilot PowerShell cmdlets and they were able to do exactly what I wanted. I could pull a list of devices by Purchase Order using

My issue now is that once I pull the information using the Get-AutoPilotDevice cmdlet, I have a group of Purchase Order IDs that I put to an outvariable. I’d like to use that outvariable along with Add-AzureADGroupMember cmdlet to add the devices to an Azure AD Group, but getting errors that the Add-AzureADGroupMember cmdlet cant take arrays, only strings. The information in the variable is on the actual PO IDs, so not sure of the error.

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [July 22, 2020, 8:00am UTC](https://forums.powershell.org/t/trying-to-use-powershell-to-get-autopilot-information-from-intune/14691/5 "2020-07-22T08:00:37Z")

</div>

“I have a group of Purchase Order IDs that I put to an outvariable”

Sounds like you need to use a For/FoEach loop on the array returned in your variable. If we could see your code, that might help.

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [July 22, 2020, 9:27am UTC](https://forums.powershell.org/t/trying-to-use-powershell-to-get-autopilot-information-from-intune/14691/6 "2020-07-22T09:27:45Z")

</div>

Have you tried my suggestion?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:29pm UTC](https://forums.powershell.org/t/trying-to-use-powershell-to-get-autopilot-information-from-intune/14691/7 "2024-05-16T20:29:10Z")

</div>


