question

RichardHowse-3657 avatar image
1 Vote"
RichardHowse-3657 asked RichardHowse-4183 edited

Whencreated date is incorrect

Hello,

I'm building a script that lists all office365 groups with their attributes so we can remove the unused ones. When i get the date of creation, whencreated gives me a completely incorrect date. I get the same result with get-group and get-unifiedgroup. Am i doing something wrong, or is this a bug i should submit?

Thank you



82409-powershell1.png
82455-powershell2jpg.jpg


windows-server-powershell
powershell1.png (181.6 KiB)
powershell2jpg.jpg (59.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

Are you running that PowerShell Get-Group from a machine in an on-premises Active Directory network? If you are, the information should be from your local AD, not the group in M365.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichardHowse-3657 avatar image
0 Votes"
RichardHowse-3657 answered

Yes the server is part on a on premise AD. I tried running the command from a computer not part of the AD, and i'm getting the same result.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

Use the Exchange Online PowerShell V2 module to connect to Exchange Online PowerShell. Then use Get-UnifiedGroup, or Get-Group, as appropriate.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichardHowse-3657 avatar image
0 Votes"
RichardHowse-3657 answered RichMatheisen-8856 commented

I tried the Exchange Online PowerShell V2 with Connect-ExchangeOnline rather than Connect-EXOPSSession i was using. Same result.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Have you imported that session?

0 Votes 0 ·
RichardHowse-3657 avatar image
0 Votes"
RichardHowse-3657 answered KreVergmann-0301 published

yes i tried:

$sfbSession = New-CsOnlineSession
Import-PSSession $sfbSession

Same result.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Did you ever find out anything? I have exactly the same problem.

0 Votes 0 ·
LopaDas avatar image
0 Votes"
LopaDas answered

Does anyone have a resolution to this? I am seeing the same behavior, with Exchange Online PowerShell V2 as of Feb 2022. WhenCreated gives wrong date. If I fetch other dates like last email receive dby group email or last SPO itemusermoddate, I get much older dates.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichardHowse-4183 avatar image
0 Votes"
RichardHowse-4183 answered

To get the correct creation date/time, i had to get it from azure ad via the microsoft graph api. You can find a intro tutorial here:

http://woshub.com/access-azure-microsoft-graph-api-powershell/

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichardHowse-4183 avatar image
0 Votes"
RichardHowse-4183 answered RichardHowse-4183 edited


At this section you can modify the $grapgroupurl to search for a particular group:


You can display the date when an Azure AD group was created:

$GrapGroupUrl = 'https://graph.microsoft.com/v1.0/Groups/'
$Groups=(Invoke-RestMethod -Headers @{Authorization = "Bearer $($token)"} -Uri $GrapGroupUrl -Method Get).value
$Groups | select displayName,createdDateTime


Like this: "https://graph.microsoft.com/v1.0/Groups?`$filter=(id eq '$graphid')"

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.