microsoftgraph / msgraph-metadata

Microsoft Graph metadata captured and used for generating client library code files.
https://graph.microsoft.com
MIT License
107 stars 33 forks source link

Microsoft.Graph.Reports - Get-MgReportOffice365ActiveUserCount #223

Open weyCC81 opened 2 years ago

weyCC81 commented 2 years ago

Output to Commandline,Pipline not possible with the following Cmdlet:

Select-MgProfile -Name "beta" Get-MgReportOffice365ActiveUserCount -Period D30 -Debug

Error:

Get-MgReportOffice365ActiveUserCount : Expected '{' or '['. Was String: Report.

Environment:

Module "Microsoft.Graph" Version "1.11.0 "

Debug:

DEBUG: [CmdletBeginProcessing]: - Get-MgReportOffice365ActiveUserCount begin processing with parameterSet 'Get1'. DEBUG: [Authentication]: - AuthType: 'Delegated', AuthProviderType: 'InteractiveAuthenticationProvider', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph PowerShell'. DEBUG: [Authentication]: - Scopes: [AuditLog.Read.All, Directory.Read.All, openid, profile, Reports.Read.All, SecurityEvents.Read.All, email]. DEBUG: ============================ HTTP REQUEST ============================ HTTP Method: GET Absolute Uri: https://graph.microsoft.com/beta/reports/microsoft.graph.getOffice365ActiveUserCounts(period='D30') Headers: Body: DEBUG: ============================ HTTP RESPONSE ============================

Status Code: OK

Headers: Pragma : no-cache Transfer-Encoding : chunked X-XSS-Protection : 1; mode=block X-Content-Type-Options : nosniff Strict-Transport-Security : max-age=31536000; includeSubDomains X-Frame-Options : Deny Content-Security-Policy : frame-options requestId : [requestid] Cache-Control : no-store, no-cache, max-age=0, s-maxage=0, private Date : Tue, 15 Nov 2022 12:42:22 GMT Server : Microsoft-IIS/10.0 X-Powered-By : ASP.NET

Body: Report Refresh Date,Office 365,Exchange,OneDrive,SharePoint,Skype For Business,Yammer,Teams,Report Date,Report Period 2022-11-14,,,,,,,,2022-10-16,30 2022-11-14,,,,,,,,2022-10-17,30 2022-11-14,,,,,,,,2022-10-18,30 2022-11-14,,,,,,,,2022-10-19,30 2022-11-14,,,,,,,,2022-10-20,30 2022-11-14,,,,,,,,2022-10-21,30 2022-11-14,,,,,,,,2022-10-22,30 2022-11-14,,,,,,,,2022-10-23,30 2022-11-14,,,,,,,,2022-10-24,30 2022-11-14,,,,,,,,2022-10-25,30 2022-11-14,,,,,,,,2022-10-26,30 2022-11-14,,,,,,,,2022-10-27,30 2022-11-14,,,,,,,,2022-10-28,30 2022-11-14,,,,,,,,2022-10-29,30 2022-11-14,,,,,,,,2022-10-30,30 2022-11-14,,,,,,,,2022-10-31,30 2022-11-14,,,,,,,,2022-11-01,30 2022-11-14,,,,,,,,2022-11-02,30 2022-11-14,1,,,1,,,1,2022-11-03,30 2022-11-14,,,,,,,,2022-11-04,30 2022-11-14,,,,,,,,2022-11-05,30 2022-11-14,,,,,,,,2022-11-06,30 2022-11-14,1,,,1,,,,2022-11-07,30 2022-11-14,,,,,,,,2022-11-08,30 2022-11-14,,,,,,,,2022-11-09,30 2022-11-14,1,,,1,,,,2022-11-10,30 2022-11-14,,,,,,,,2022-11-11,30 2022-11-14,,,,,,,,2022-11-12,30 2022-11-14,,,,,,,,2022-11-13,30 2022-11-14,,,,,,,,2022-11-14,30

DEBUG: [CmdletException]: Received exception with message 'ParserException - Expected '{' or '['. Was String: Report. : at Microsoft.Graph.PowerShell.Runtime.Json.JsonParser.ReadNode() at Microsoft.Graph.PowerShell.Runtime.Json.JsonNode.Parse(SourceReader sourceReader) at Microsoft.Graph.PowerShell.Reports.<>c.b421_0(Task1 body) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.PowerShell.Cmdlets.GetMgReportOffice365ActiveUserCount_Get1.d53.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.PowerShell.Reports.d421.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Graph.PowerShell.Reports.d421.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.PowerShell.Reports.d419.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Graph.PowerShell.Cmdlets.GetMgReportOffice365ActiveUserCount_Get1.d50.MoveNext()' Get-MgReportOffice365ActiveUserCount : Expected '{' or '['. Was String: Report. At line:1 char:1

  • Get-MgReportOffice365ActiveUserCount -Period D30 -Debug #v1-0: -OutF ...
  • 
    + CategoryInfo          : NotSpecified: (:) [Get-MgReportOff...eUserCount_Get1], ParserException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgReportOffice365ActiveUserCount_Get1

DEBUG: [CmdletEndProcessing]: - Get-MgReportOffice365ActiveUserCount end processing.

peombwa commented 2 years ago

Thanks for bringing this to our attention.

The error is due to how the API response is described in the CSDL service metadata. The metadata says the API should return a JSON object, yet it returns a CSV file:

<Function Name="getOffice365ActiveUserCounts" IsBound="true" IsComposable="true">
  <Parameter Name="reportRoot" Type="graph.reportRoot" />
  <Parameter Name="period" Type="Edm.String" Nullable="false" Unicode="false" />
  <ReturnType Type="Collection(graph.office365ActiveUserCounts)" Nullable="false" />
</Function>

The ideal representation should be:

 <Function Name="getOffice365ActiveUserCounts" IsBound="true" IsComposable="true">
  <Parameter Name="bindingParameter" Type="graph.reportRoot" />
  <Parameter Name="period" Type="Edm.String" Nullable="false" Unicode="false" />
  <ReturnType Type="graph.Report" Nullable="false" />
</Function>

As workaround, you can use the v1.0 version of the command to download the CSV file:

Select-MgProfile v1.0
Get-MgReportOffice365ActiveUserCount -Period D30 -OutFile "ActiveUserCount.csv"

I'll transfer the issue to the metadata repository.