Skip to content

Get-MgReportSharePointSiteUsageDetail204B is failing #894

@maisarissi

Description

@maisarissi

Per the documentation I should be able to use the cmdlet as follows:

Get-MgReportSharePointSiteUsageDetail204B -Period "D90" -OutFile "C:\Development\PowerShell\MyFile.csv"

Besides the weird cmdlet name, I'm getting an error:

DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(period='D90')
DEBUG: RequestCreated: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(period='D90')
DEBUG: HeaderParametersAdded: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(period='D90')
DEBUG: GET /v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(period='D90') HTTP/1.1
HTTP: graph.microsoft.com
DEBUG: BeforeCall:
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletException: InvalidOperationException - The stream was already consumed. It cannot be read again. : at System.Net.Http.HttpConnectionResponseContent.ConsumeStream()
at System.Net.Http.HttpConnectionResponseContent.CreateContentReadStreamAsync()
at System.Net.Http.HttpContent.CreateContentReadStreamAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpContent.ReadAsStreamAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpContent.ReadAsStreamAsync()
at Microsoft.Graph.PowerShell.HttpMessageFormatter.b__28_0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Microsoft.Graph.PowerShell.HttpMessageFormatter.TryComputeLength(Int64& length)
at System.Net.Http.HttpContent.GetComputedOrBufferLength()
at System.Net.Http.Headers.HttpContentHeaders.get_ContentLength()
at System.Net.Http.HttpContent.CreateMemoryStream(Int64 maxBufferSize, Exception& error)
at System.Net.Http.HttpContent.CreateTemporaryBuffer(Int64 maxBufferSize, MemoryStream& tempBuffer, Exception& error)
at System.Net.Http.HttpContent.LoadIntoBufferAsync(Int64 maxBufferSize, CancellationToken cancellationToken)
at System.Net.Http.HttpContent.ReadAsStringAsync(CancellationToken cancellationToken)
at System.Net.Http.HttpContent.ReadAsStringAsync()
at Microsoft.Graph.PowerShell.Module.Finally(String id, CancellationToken cancellationToken, Func`1 getEventData, Func`4 signal)
at Microsoft.Graph.PowerShell.Module.EventHandler(String id, CancellationToken cancellationToken, Func`1 getEventData, Func`4 signal, InvocationInfo invocationInfo, String parameterSetName, Exception exception)
at Microsoft.Graph.PowerShell.Module.Signal(String id, CancellationToken token, Func`1 getEventData, Func`4 signal, InvocationInfo invocationInfo, String parameterSetName, Exception exception)
at Microsoft.Graph.PowerShell.Cmdlets.GetMgReportSharePointSiteUsageDetail204B_Get.Microsoft.Graph.PowerShell.Runtime.IEventListener.Signal(String id, CancellationToken token, Func`1 messageData)
at Microsoft.Graph.PowerShell.Reports.ReportsGetSharePointSiteUsageDetail204B_Call(HttpRequestMessage request, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Graph.PowerShell.Reports.ReportsGetSharePointSiteUsageDetail204B(String period, Func`3 onOk, Func`3 onDefault, IEventListener eventListener, ISendAsync sender)
at Microsoft.Graph.PowerShell.Cmdlets.GetMgReportSharePointSiteUsageDetail204B_Get.ProcessRecordAsync()
at Microsoft.Graph.PowerShell.Cmdlets.GetMgReportSharePointSiteUsageDetail204B_Get.ProcessRecordAsync()
Get-MgReportSharePointSiteUsageDetail204B_Get: The stream was already consumed. It cannot be read again.
DEBUG: CmdletProcessRecordEnd:
DEBUG: CmdletEndProcessing:

As a workaround, I can successfully call Invoke-MgGraphRequest:

$url = "https://graph.microsoft.com/v1.0/reports/getSharePointSiteUsageDetail(period='D90')"
Invoke-MgGraphRequest -Method Get -Uri $url -OutputFilePath "C:\Development\PowerShell\MyFile.csv"

There is also another cmdlet to get sites usage, but per date (not sure why there are 2 different cmdlets instead of the same cmdlet but using different parameters):

Get-MgReportSharePointSiteUsageDetailD27A -Date 2021-10-05 -OutFile "C:\Development\PowerShell\MyFile.csv"

And I'm getting this error:

DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05)
DEBUG: RequestCreated: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05)
DEBUG: HeaderParametersAdded: https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05)
DEBUG: GET /v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05) HTTP/1.1
HTTP: graph.microsoft.com
DEBUG: BeforeCall:
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
Get-MgReportSharePointSiteUsageDetailD27A_Get: Expression expected at position 5 in 'date==2021-10-05'.
DEBUG: GET https://graph.microsoft.com/v1.0/reports/microsoft.graph.getSharePointSiteUsageDetail(date==2021-10-05)
HTTP/1.1 400 Bad Request
Date: Wed, 06 Oct 2021 19:00:03 GMT
Transfer-Encoding: chunked
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000
request-id: c70c031d-4298-4b30-8987-a5046ecf0bf6
client-request-id: c70c031d-4298-4b30-8987-a5046ecf0bf6
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Brazil South","Slice":"E","Ring":"3","ScaleUnit":"002","RoleInstance":"CP1PEPF0000287F"}}
Content-Type: application/json
Content-Encoding: gzip
{"error":{"code":"BadRequest","message":"Expression expected at position 5 in 'date==2021-10-05'.","innerError":{"date":"2021-10-06T19:00:03","request-id":"c70c031d-4298-4b30-8987-a5046ecf0bf6","client-request-id":"c70c031d-4298-4b30-8987-a5046ecf0bf6"}}}
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: CmdletEndProcessing:

And it's also possible to do the workaround for this scenario using Invoke-MgGraphRequest:

$url = "https://graph.microsoft.com/v1.0/reports/getSharePointSiteUsageDetail(date=2021-10-05)"
Invoke-MgGraphRequest -Method Get -Uri $url -OutputFilePath "C:\Development\PowerShell\MyFile.csv"

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions