I am trying to export every group within my organisation and their owner(s) if possible Also to return no owner or remain blank if no owner is assigned
I am new to azure powershelgl so am starting from zero here
I have looked through numerous other threads but don't seem to find any that returns owners owners only group members. I don't necessarily need the membership of these groups just the name of the group, the owners and export this to CSV
Thank you for any assistance
I haven't really tried anything as I am very new to azure powershell and also unable to find anything online
01 Answer
I tried to reproduce the same in my environment and got the results successfully like below:
To import the list of Azure AD Groups and its owners, use the below Powershell Script:
connect-AzureAD $groups = Get-AzureADGroup -All $true $result = foreach ($group in $groups) { Get-AzureADGroupOwner -ObjectId $group.ObjectId -All $true | ForEach-Object { [PsCustomObject]@{ 'Group' = $group.DisplayName 'Owner' = $_.UserPrincipalName } } } $result | Format-Table -AutoSize $result | Export-Csv -Path 'C:\users\testkhann.csv' -NoTypeInformation 
The Csv File imported successfully like below:
