Assistance Needed with OneDrive and Office 365 Activity PowerShell Scripts

Dear All,

I am using the scripts below to retrieve OneDrive and Office 365 activity details for my tenant. However, in the “User Principal Name” field, I am getting an ID instead of the email address. This issue started recently; prior to that, it was working fine and showing the email addresses as expected.

I run these scripts daily and generate a Power BI report based on the output.

Scripts
Invoke-GraphApiRequest -uri “https://graph.microsoft.com/v1.0/reports/getOneDriveActivityUserDetail(date=$yesterdaydate)” -FileName “OneDrive\ODUserDailyActivity\OneDriveUserDailyActivity” -Verbose:$VerbosePreference

Invoke-GraphApiRequest -uri “https://graph.microsoft.com/v1.0/reports/getOneDriveUsageAccountDetail(date=$yesterdaydate)” -FileName “OneDrive\ODUsageDailyReport\OneDriveUsageDailyReport” -Verbose:$VerbosePreference

Here is an example of the output I’m receiving:

Report Refresh Date,User Principal Name,Is Deleted,Deleted Date,Last Activity Date,Viewed Or Edited File Count,Synced File Count,Shared Internally File Count,Shared Externally File Count,Assigned Products,Report Period 2024-11-22,830E1CDE8B16F21C80B207D213852737,False,2024-11-22,1,0,0,0,MICROSOFT COPILOT STUDIO VIRAL TRIAL+MICROSOFT 365 E5+MICROSOFT COPILOT STUDIO USER LICENSE+MICROSOFT POWER AUTOMATE FREE+MICROSOFT INTUNE SUITE+MICROSOFT FABRIC (FREE)+MICROSOFT DEFENDER VULNERABILITY MANAGEMENT ADD-ON+DYNAMICS 365 CUSTOMER VOICE TRIAL+PLANNER AND PROJECT PLAN 3+POWER APPS PREMIUM+MICROSOFT POWER APPS FOR DEVELOPER,1

This is just one example, but I am seeing similar results for most of these scripts.

Could you please help me resolve this issue?

Thank you in advance!

Hi, welcome to the forum :wave:

Firstly, when posting code or output in the forum, please can you use the preformatted text </> button. It really helps us with readability, and copying and pasting your code (we don’t have to faff about replacing curly quote marks to get things working). If you can’t see the </> in your toolbar, you will find it under the gear icon.

What module are you using for Invoke-GraphApiRequest ? As far as I can tell this is not an official cmdlet as the cmdlet in the Graph SDK is Invoke-GraphRequest and it does not have any aliases.

What output do you get with the Graph SDK cmdlet?

Invoke-GraphRequest -Uri "https://graph.microsoft.com/v1.0/reports/getOneDriveActivityUserDetail(date=2024-11-26)" -OutputFilePath 'E:\Temp\output'

If the output with the SDK is incorrect then something has changed with the Graph API. That doesn’t appear to be a user ID so you can’t just pass it to Get-MgUser.

If the output is OK with the SDK then it’s a problem with the module you’re using. Contact the author(s) for support.