Skip to content

Instantly share code, notes, and snippets.

@EvertonSA
Last active November 4, 2023 23:38
Show Gist options
  • Save EvertonSA/93f5bf21ddaecc2dc6798619aeb2651a to your computer and use it in GitHub Desktop.
Save EvertonSA/93f5bf21ddaecc2dc6798619aeb2651a to your computer and use it in GitHub Desktop.
create_200_groups_and_add_guest_user_to_all
$guest_objectId = "8093ba8f-255a-48bf-9968-bf49b8c983e1"
# Generate a list of 200 random group names
$groupNames = @()
for ($i = 0; $i -lt 200; $i++) {
$groupName = New-Guid
$groupNames += "$groupName"
}
# Create the groups
foreach ($groupName in $groupNames) {
New-AzureADMSGroup -DisplayName $groupName -Description "Group assignable to role" -MailEnabled $False -MailNickname "helpDeskAdminGroup" -SecurityEnabled $True -Visibility "Private"
}
# Add the user to all of the groups
foreach ($groupName in $groupNames) {
$group = Get-AzureADGroup -SearchString $groupName
Add-AzureADGroupMember -ObjectId $group.ObjectId -RefObjectId $guest_objectId
}
@EvertonSA
Copy link
Author

image

@EvertonSA
Copy link
Author

image

@EvertonSA
Copy link
Author

EvertonSA commented Nov 4, 2023

Microsoft Entra ID id token for user with 5 group membership

{
  "aud": "6b99b0d8-00c4-4a81-b7c8-6194b562f9e6",
  "iss": "https://login.microsoftonline.com/f07b1c6c-04ed-4659-8a39-6b38b1147855/v2.0",
  "iat": 1699138452,
  "nbf": 1699138452,
  "exp": 1699142352,
  "groups": [
    "79e6ee00-2c47-4918-a150-6c66e8f7e4ed",
    "80df2804-c358-4434-94b5-da948f142bfe",
    "7c8b267c-f0f5-49d7-9fc8-04df3351b67d",
    "84047086-a0e3-4ff9-bed0-abb94003e2e8",
    "7def1f90-6a36-41b3-a949-d159898870c8",
    "84300eb3-d3af-4af3-b111-f503dbe83bd7"
  ],
  "idp": "https://sts.windows.net/9188040d-6c67-4c5b-b112-36a304b66dad/",
  "nonce": "cMdcMIixZgDh94gHh3ik",
  "prov_data": [
    {
      "at": true,
      "prov": "github.com",
      "altsecid": "30481051"
    }
  ],
  "rh": "0.Aa4AbBx78O0EWUaKOWs4sRR4VdiwmWvEAIFKt8hhlLVi-earAGY.",
  "sub": "4MyKRi9ILppS_iMm7oB0RupNVCTQ2T7DPTF5LnHxPgk",
  "tid": "f07b1c6c-04ed-4659-8a39-6b38b1147855",
  "uti": "4kOGsY-B40S8mT_lJ7BCAA",
  "ver": "2.0",
  "wids": [
    "13bd1c72-6f4a-4dcf-985f-18d3b80f208a"
  ]
}

and id token for user with exact 200 groups

{
  "aud": "6b99b0d8-00c4-4a81-b7c8-6194b562f9e6",
  "iss": "https://login.microsoftonline.com/f07b1c6c-04ed-4659-8a39-6b38b1147855/v2.0",
  "iat": 1699137656,
  "nbf": 1699137656,
  "exp": 1699141556,
  "_claim_names": {
    "groups": "src1"
  },
  "_claim_sources": {
    "src1": {
      "endpoint": "https://graph.windows.net/f07b1c6c-04ed-4659-8a39-6b38b1147855/users/00000000-0000-0000-0000-000000000000/getMemberObjects"
    }
  },
  "idp": "https://sts.windows.net/9188040d-6c67-4c5b-b112-36a304b66dad/",
  "nonce": "MNo6IVsgHVn4ie0llOhF",
  "prov_data": [
    {
      "at": true,
      "prov": "github.com",
      "altsecid": "30481051"
    }
  ],
  "rh": "0.Aa4AbBx78O0EWUaKOWs4sRR4VdiwmWvEAIFKt8hhlLVi-earAJ8.",
  "sub": "4MyKRi9ILppS_iMm7oB0RupNVCTQ2T7DPTF5LnHxPgk",
  "tid": "f07b1c6c-04ed-4659-8a39-6b38b1147855",
  "uti": "Bx4xNwd4NkWK_yGgUEJDAA",
  "ver": "2.0",
  "wids": [
    "13bd1c72-6f4a-4dcf-985f-18d3b80f208a"
  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment