Skip to content

Instantly share code, notes, and snippets.

@SBajonczak
Created January 3, 2022 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SBajonczak/9fc4b1e1aa7f54ca3523658ddbf60f8b to your computer and use it in GitHub Desktop.
Save SBajonczak/9fc4b1e1aa7f54ca3523658ddbf60f8b to your computer and use it in GitHub Desktop.
Importing Groups from an array into the Azure AD
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