Forum Discussion

LUCA NAVIGLIO's avatar
LUCA NAVIGLIO
Copper Contributor
Aug 06, 2025

Can't add device member in Static Security Entra Group with powershell

Hi,

With Graph, I want to add some device members in a static security Entra group using it to deploy some certificates with Intune.

I do it with following command:

New-MgGroupMember -GroupId $groupId -DirectoryObjectId $device.AzureAdDeviceId

but I receive this error:

New-MgGroupMember : Resource 'df75dfe1-8b5a-4cc6-8f99-17746bb8c07e' does not exist or one of its queried reference-property objects are not present.
In C:\Users\E21996\OneDrive - Fondazione Enasarco\Lavoro\!HelpDesk\!Intune\Scripts\Set-Device-Department-Attribute.ps1:57 car:9
+         New-MgGroupMember -GroupId $groupId -DirectoryObjectId $devic ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ({ GroupId = 9fa...ferenceCreate }:<>f__AnonymousType1`2) [New-MgGroupMember_CreateExpanded], Exception
    + FullyQualifiedErrorId : Request_ResourceNotFound,Microsoft.Graph.PowerShell.Cmdlets.NewMgGroupMember_CreateExpanded

I've checked the GroupID and Azure Device ID and are correct.

If I try to add a user it works fine, with device I have this error.

In the group I can add device member manually from Intune without problems.

There is a known issue when add device members to groups in Graph?
Can anyone help me to resolve this issue, please?

1 Reply

  • This does work.

    New-MgGroupMember -GroupId XYZ -DirectoryObjectId (Get-MgDevice -Filter "displayName eq 'COMPUTERNAME' ").Id

     It queries using Graph for the device ID in the process using the display name of the device.

     

     

Resources