Copy Azure AD Cloud Groups to Another User

I am struggling on how to copy all Azure AD groups from one user to another. I used the command below and the Azure AD Groups copy successfully but it also tries to copy the the traditional AD groups which I do not want.

$membershipGroups = Get-AzureADUserMembership -ObjectId user@domain.com

I have tried the command and filter below to filter out the traditional AD groups but it doesn’t work.

$membershipGroups = Get-AzureADUserMembership -ObjectId $user1Obj.ObjectId | where-Object {$_.OnPremisesSecurityIdentifier -eq $false}

Any help would be greatly appreciated. I just want to copy azure AD groups from one user to another using powershell.

Thank you

I figured it out. The filter had to be | where-Object {$_.DirSyncEnabled -eq $NULL}

JC,

anyway … ,
Welcome to the forum. :wave:t4:

And thanks for sharing your solution. :+1:t4:

Here’s something more to such a filter / comparison you might want to consider anyway:

Next time please … When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink: