Created
January 3, 2022 19:33
-
-
Save SBajonczak/9fc4b1e1aa7f54ca3523658ddbf60f8b to your computer and use it in GitHub Desktop.
Importing Groups from an array into the Azure AD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach ($group in $groups) | |
{ | |
$name = $group.Name | |
$owner = $group.Owner | |
$foundElement = get-azureadgroup -SearchString $name | |
if ($foundElement) | |
{ | |
Write host "$name already exists" | |
} else | |
{ | |
Write host "$name does not exists! ... Creating it" | |
$adGroup = New-AzureADGroup -DisplayName $name -MailEnabled $false -SecurityEnabled $true -MailNickName "NotSet" | |
Write-Host "Group created with Id $adGroup.ObjectId" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment