Forum Discussion

hdsouza1's avatar
hdsouza1
Copper Contributor
Nov 05, 2026
Solved

Get-MgReportMailboxUsageDetail fails with : Cannot access a closed Stream

Since Nov 3 at 10 PM EST Get-MgReportMailboxUsageDetail fails with "Cannot access a closed Stream"

The command used is : Get-MgReportMailboxUsageDetail -Period D7 -OutFile C:\Temp\test.csv

Has anyone encountered this error in the last 3 days?

Also this works fine: Get-MgReportMailboxUsageStorage -Period D7 -OutFile C:\Temp\Test.csv …. Which should imply  that the access and session is fine.

  • Works fine here, perhaps some temporary issue?

    You can always get the data as JSON instead, and use Export-CSV against it:

    $a = Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/reports/microsoft.graph.getMailboxUsageDetail(period='D7')?`$format=application/json" -OutputType PSObject
    $a.value | Export-Csv D:\Downloads\temp.csv

     

2 Replies

  • hdsouza1's avatar
    hdsouza1
    Copper Contributor

    Thanks VasilMichev.

    That command worked, although it gave me only 200 users (Pagination).

    Although I noticed you are using the "Beta" version.

    I just tried installing the corresponding Get-MgBetaReportMailboxUsageDetail and that worked as well for all 42K users

     

    Then I went and updated graph modules from 2.29.1 to 2.41.2 and with that Get-MgReportMailboxUsageDetail also works now.

  • Works fine here, perhaps some temporary issue?

    You can always get the data as JSON instead, and use Export-CSV against it:

    $a = Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/reports/microsoft.graph.getMailboxUsageDetail(period='D7')?`$format=application/json" -OutputType PSObject
    $a.value | Export-Csv D:\Downloads\temp.csv