Trying to use PowerShell to get AutoPilot information from Intune

Welcome Forums General PowerShell Q&A Trying to use PowerShell to get AutoPilot information from Intune

Viewing 5 reply threads
  • Author
    Posts
    • #243929
      Participant
      Topics: 2
      Replies: 3
      Points: 32
      Rank: Member

      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.

    • #243932
      Participant
      Topics: 7
      Replies: 123
      Points: 599
      Helping Hand
      Rank: Major Contributor

      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?

    • #243938
      Participant
      Topics: 8
      Replies: 568
      Points: 2,170
      Helping Hand
      Rank: Community Hero

      Hi Brian,

      You may try this, it worked for HWID.

      Here are some helpful links. It seems this command and module are limited.

      Filtering users and groups with the Azure AD (Graph) ODATA syntax


      https://docs.microsoft.com/en-us/previous-versions/azure/ad/graph/howto/azure-ad-graph-api-supported-queries-filters-and-paging-options

    • #244073
      Participant
      Topics: 2
      Replies: 3
      Points: 32
      Rank: Member

      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.

    • #244136
      Participant
      Topics: 7
      Replies: 123
      Points: 599
      Helping Hand
      Rank: Major Contributor

      “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.

    • #244163
      Participant
      Topics: 8
      Replies: 568
      Points: 2,170
      Helping Hand
      Rank: Community Hero

      Have you tried my suggestion?

Viewing 5 reply threads
  • You must be logged in to reply to this topic.