Table of Contents
This article will show you how to get the creation date of all your Azure Active Directory groups using a PowerShell script. This is important for auditing purposes and can be used in other scripts to remove any groups that were created after a certain date.
Connect to Microsoft Graph PowerShell
To perform this task, you need install Microsoft Graph PowerShell modules before you can connect to Microsoft Graph API.
1. Before you begin, let’s install the modules following this article.
2. Connect to Microsoft Graph using required scope then sign-in using a global admin account.
Connect-MgGraph -Scope Group.Read.All3. Run the following script to get the CreatedDateTime of all Microsoft 365 groups in a tenant.
$Report = @()
$Groups = Get-MgGroup -All
foreach ($Group in $Groups) {
    $ObjReport = [PSCustomObject]@{
    DisplayName = $Group.DisplayName    
    Mail     = $Group.Mail
    CreationDate  = $Group.CreatedDateTime
    }
$Report += $ObjReport
}
$Report | Format-Table$Report | Format-Table
DisplayName Mail                            CreationDate
----------- ----                            ------------
Finance     [email protected]            7/25/2022 3:33:15 PM
M365G       [email protected]              7/18/2022 3:06:48 PM
SSPS        [email protected]               8/8/2022 7:13:41 AM
IT          [email protected]                 8/4/2022 2:24:52 PM
Bon Ben     [email protected]          7/25/2022 2:08:50 PM
Bon Ben     [email protected] 7/3/2022 4:30:40 AM
DL1         [email protected]                7/18/2022 3:11:24 PM
Rest of R&D [email protected]               7/26/2022 4:08:17 AM
R&D         [email protected]                7/26/2022 4:05:59 AMYou can export the results output to a csv file using following command:
$Report | Export-Csv C:\Report_GroupCreatedDate.csv -Nti
Get CeatedDate for a single group
In some cases, you just need get the creation date for a single group only.
1. First, run Get-MgGroup command to find out the group ids.
Get-MgGroup -All
Id                                   DisplayName Description                                                   GroupTypes AccessType
--                                   ----------- -----------                                                   ---------- ----------
181b9ed2-ecf8-49da-bca1-7088af72251f Finance                                                                   {Unified}
1d60a3e4-04ad-4631-bcca-4e5c8d3a6a81 M365G       M365G                                                         {Unified}
43678fdb-2e72-410d-807c-1ee4f89628ef SSPS        SSPS                                                          {Unified}
74029cc4-4776-43ad-9fbd-946ee7ee040d IT                                                                        {Unified}
76c65d3f-4baf-47d2-941f-769d3fed9e0e Bon Ben     Check here for organization announcements and important info. {Unified}
7fa305ba-61ef-4340-9d71-0ff9fa79192f Bon Ben     Bon Ben                                                       {Unified}
a4bb6c1d-d485-484b-87e6-bfb298abb3fd DL1         DL1                                                           {}
c00c4ca7-cb70-407c-868c-5914b8a31578 Rest of R&D Rest of R&D                                                   {Unified}
c16931e9-4771-442d-af64-389b3ea06244 R&D         R&D                                                           {Unified}Or you can run the following command to get all groups whose display name contains ‘Finance‘.
Get-MgGroup -All -ConsistencyLevel eventual -Count GroupCount -Search '"Displayname:Finance"'
Id                                   DisplayName Description GroupTypes AccessType
--                                   ----------- ----------- ---------- ----------
181b9ed2-ecf8-49da-bca1-7088af72251f Finance                 {Unified}2. Finally, run the following command to export the CreatedDate of a group.
(Get-MgGroup -GroupId 181b9ed2-ecf8-49da-bca1-7088af72251f).CreatedDateTime
Monday, July 25, 2022 3:33:15 PM 
			


