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 $trueForEach ($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
What I want is to remove them from Azure.
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