12Knocksinna / Office365itpros

Office 365 for IT Pros PowerShell examples
MIT License
1.28k stars 567 forks source link

No Last SPO Activity in TeamsGroupsActivityReportV5.PS1 #51

Closed FabioOzitem closed 2 years ago

FabioOzitem commented 2 years ago

Hello,

When i'm running TeamsGroupsActivityReportV5.PS1 I don't have any data in last SPO Activity column. Not sure if it's expected.

image Data from a test O365 Tenant.

Thank you !

12Knocksinna commented 2 years ago

What version of the script are you running (5.5 is the current). Also, does the app have the permission to read sites information (Sites.Read.All)

FabioOzitem commented 2 years ago

Hello @12Knocksinna, Thank you for replying ! Yes i'm running version 5.5. I've added sites.read.all but column is still empty. I've tried as well with 5.6 and not much better. ! image

Do i miss some right ?

12Knocksinna commented 2 years ago

What happens when you run:

$SPOUsageReportsURI = "https://graph.microsoft.com/v1.0/reports/getSharePointSiteUsageDetail(period='D180')" $SPOUsage = (Invoke-RestMethod -Uri $SPOUsageReportsURI -Headers $Headers -Method Get -ContentType "application/json") -Replace "...Report Refresh Date", "Report Refresh Date" | ConvertFrom-Csv

Does any information show up in $SPOUsage?

FabioOzitem commented 2 years ago

Yes.

image

12Knocksinna commented 2 years ago

I assume then that the $Datatable (hash table containing SPO usage data) is populated.

Later, the hash table is looked up for the usage data as each group is processed:

If ($G.SharePointURL -ne $Null) {
If ($Datatable[$G.SharePointURL]) { # Look up hash table to find usage information for the site $ThisSiteData = $Datatable[$G.SharePointURL] $SPOFileCount = $ThisSiteData.FileCount $SPOStorageUsed = $ThisSiteData.StorageUsed $SPOLastActivityDate = $ThisSiteData.LastActivityDate If ($SPOLastActivityDate -ne $Null) { $DaysSinceLastSPOActivity = (New-TimeSpan -Start $SPOLastActivityDate -End $Today).Days }

You could check by populating $G with details of a group to see if the lookup works. For example:

$G = Get-UnifiedGroup -Identity "Test Group" ($Datatable[$G.SharePointSiteURL])

Name Value


StorageUsed 1.54 GB DisplayName Exchange GOMs LastActivityDate 14/07/2022 FileCount 8085

FabioOzitem commented 2 years ago

It makes me realise that $shareddocfolder wasn't configured for my french library...

   $SharedDocFolder = "/Documents%20partages" # These values are to allow internationalization of the SPO document library URL. For French, this would be "/Documents%20partages" 
   $SharedDocFolder2 = "/Documents partages"  # Add both values

I lost myself a bit after adding certificate auth to exchange online part :)

if Sites.Read.All, is really needed it could be worth adding it to comment section of your script where it's currently missing :)

# V5.6 19-Jul-2022 Add email address of team owner to output and updated activity range for usage reports to 180 days
#
# https://github.com/12Knocksinna/Office365itpros/blob/master/TeamsGroupsActivityReport.ps1
#
# Needs the following Graph permissions:
# Group.Read.All, Reports.Read.All, User.Read.All, GroupMember.Read.All
#
#+-------------------------- Functions etc. -------------------------
12Knocksinna commented 2 years ago

Funny... I realized that Sites.Read.All wasn't in the set listed earlier today and updated the script.