Forum Discussion
M365Power
Apr 03, 2023Copper Contributor
SharePoint sites and data enterprise cost allocation
From an admin standpoint how could you manage cost centers / cost allocation to SharePoint Online Farm? Would be ideal to add a custom column in the SharePoint admin center to the sites so that cost ...
M365Power
Apr 07, 2023Copper Contributor
Ok so I see the issue here - it is not picking up on the 365 Group Owner group. Is there a way to pick up on the 365 Group owner group?
Apr 08, 2023
This will get M365 groups. I'll have you try to see what you need to merge between this and previous script to get the output you want
Ping me if you get stuck
# Define the output file path
$OutputFile = "C:\temp\M365Groups.csv"
# Get all M365 groups
$Groups = Get-MgGroup -All
# Create an empty array to store the results
$Results = @()
# Loop through each group
foreach ($Group in $Groups) {
# Get the group owner
$Owner = Get-MgGroupOwner -GroupId $Group.Id
# Create a custom object with the group and owner details
$Object = [PSCustomObject]@{
"Group Name" = $Group.DisplayName
"Group Email" = $Group.Mail
"Group Type" = $Group.GroupTypes -join ", "
"Owner Name" = $Owner.DisplayName
"Owner Email" = $Owner.Mail
}
# Add the object to the results array
$Results += $Object
}
# Export the results to a CSV file
$Results | Export-Csv -Path $OutputFile -NoTypeInformation
# Write a message to indicate the script is done
Write-Host "The script has completed. The output file is located at $OutputFile