-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathCreate-AzureAdTestGroups.ps1
More file actions
32 lines (28 loc) · 968 Bytes
/
Create-AzureAdTestGroups.ps1
File metadata and controls
32 lines (28 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<#
.SYNOPSIS
Create test security groups in Entra ID (Azure AD)
.DESCRIPTION
Connects to Microsoft Graph and creates a specified number of test security groups.
Uses the Microsoft Graph PowerShell SDK (Connect-MgGraph / New-MgGroup) instead of
the deprecated AzureAD module.
.NOTES
Author: Jannik Reinhard (jannikreinhard.com)
Version: 2.0
#>
try {
Connect-MgGraph -Scopes "Group.ReadWrite.All" -ErrorAction Stop
$countOfTestGroups = 10
for ($i = 0; $i -lt $countOfTestGroups; $i++) {
New-MgGroup -DisplayName "zTestSecurityGroup$i" `
-SecurityEnabled `
-Description "Test group nr group $i" `
-MailEnabled:$false `
-MailNickname "NotSet" `
-ErrorAction Stop
}
Write-Host "Successfully created $countOfTestGroups test groups"
exit 0
} catch {
Write-Error "Failed to create test groups: $_"
exit 1
}