зеркало из https://github.com/Azure/AVDBlueprint.git
16 строки
617 B
PowerShell
16 строки
617 B
PowerShell
param ($groupName, $userPrincipalName)
|
|
Write-Host "Adding UPN ($userPrincipalName) to group ($groupName)"
|
|
|
|
if (-Not (Get-AzADGroup -DisplayName "$groupName")) {
|
|
$mailNickname = $groupName -replace '[\W]',''
|
|
New-AzADGroup -DisplayName "$groupName" -MailNickname $mailNickname
|
|
}
|
|
|
|
Start-Sleep 10
|
|
if (-Not (Get-AzADGroupMember -GroupDisplayName "$groupName" | Where-Object {$_.UserPrincipalName -eq $userPrincipalName})) {
|
|
$parameters = @{
|
|
TargetGroupDisplayName = "$groupName"
|
|
MemberUserPrincipalName = $userPrincipalName
|
|
}
|
|
Add-AzADGroupMember @parameters
|
|
} |