Reputation: 1
https://learn.microsoft.com/en-us/powershell/azuread/v2/add-azureadgroupmember
Add-AzureADGroupMember fails if user already exist. how to suppress error? I have tried to pass -ErrorAction parameters with "Ignore" or "SilentlyContinue" but it does not help!
command is like
Add-AzureADGroupMember -ObjectId $NewAzureADGroup.ObjectId -RefObjectId $userInformation.ObjectId
Upvotes: 0
Views: 2301
Reputation: 12434
You could wrap that argument in a "Try" "Catch" block:
Try {
Add-AzureADGroupMember -ObjectId $NewAzureADGroup.ObjectId -RefObjectId $userInformation.ObjectId
}
Catch
{
Write-Host "User Already Present in Group"
}
Otherwise you can submit a bug report on GitHub.
Upvotes: 2