Hello everyone, I need a Powershell script to get all the group owners as members on Azure AD and remove them (Office 365 groups). Could you please guys Help? Thanks
Hello everyone, I need a Powershell script to get all the group owners as members on Azure AD and remove them (Office 365 groups). Could you please guys Help? Thanks
That's not a supported scenario, an Owner must be a member of the corresponding Office 365 Group.
Where when you create an office 365 group the owner is a member by default. Is there a way to remove it?
This is my script.
What I want is to use "Remove-AzureADGroupOwner" somehow.
$groups=Get-AzureADGroup -All $true
$resultsarray =@()
ForEach ($group in $groups){
$members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All $true
ForEach ($member in $members){
$UserObject = new-object PSObject
$UserObject | add-member -membertype NoteProperty -name "Group Name" -Value $group.DisplayName
$UserObject | add-member -membertype NoteProperty -name "Member Name" -Value $member.DisplayName
$UserObject | add-member -membertype NoteProperty -name "ObjType" -Value $member.ObjectType
$UserObject | add-member -membertype NoteProperty -name "UserType" -Value $member.UserType
$UserObject | add-member -membertype NoteProperty -name "UserPrinicpalName" -Value $member.UserPrincipalName
$resultsarray += $UserObject
}
}
$resultsarray | Export-Csv -Encoding UTF8 -Delimiter ";" -Path "C:\test\output.csv" -NoTypeInformation
7 people are following this question.