You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Object cast bug when calling OData actions and functions that return a collection. #610
Calling Get-MgGroupDelta with no parameters once connected results in a object cast error.
Steps to reproduce:
Install latest version (1.4.2) of the SDK.
PS C:\Users\db> get-installedmodule microsoft.graph
Version Name Repository Description
------- ---- ---------- -----------
1.4.2 Microsoft.Graph PSGallery Microsoft Graph PowerShell module
Connect to graph
PS C:\Users\db> connect-graph -scopes "group.read.all","user.read.all"
Welcome To Microsoft Graph!
Run command
PS C:\Users\db> Get-MgGroupDelta
Get-MgGroupDelta_Delta1: Unable to cast object of type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonObject' to type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonArray'.
changed the title [-]Object cast bug in Get-MgGroupDelta[/-][+]Object cast bug when calling OData actions and functions that return a collection.[/+]on Nov 3, 2021
Same issue using cmdlet "Get-MgDirectoryObjectById"
`
DEBUG: [CmdletBeginProcessing]: - Get-MgDirectoryObjectById begin processing with parameterSet 'GetExpanded1'.
DEBUG: [Authentication]: - AuthType: 'Delegated', AuthProviderType: 'InteractiveAuthenticationProvider', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph PowerShell'.
DEBUG: [Authentication]: - Scopes: [Application.Read.All, Application.ReadWrite.All, Directory.AccessAsUser.All, Directory.Read.All, Directory.ReadWrite.All, Group.Read.All, Group.ReadWrite.All, openid, profile, User.Read, User.Read.All, email].
Confirm
Are you sure you want to perform this action?
Performing the operation "Get-MgDirectoryObjectById_GetExpanded1" on target "Call remote 'DirectoryObjectsGetByIds1' operation".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Yes"):
DEBUG: ============================ HTTP REQUEST ============================
DEBUG: [CmdletException]: Received exception with message 'InvalidCastException - Unable to cast object of type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonObject' to type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonArray'. : at Microsoft.Graph.PowerShell.Runtime.Json.JsonArray.Parse(String text)
at Microsoft.Graph.PowerShell.DirectoryObjects.<>c.<DirectoryObjectsGetByIds1_Call>b__59_0(Task1 body) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Graph.PowerShell.Cmdlets.GetMgDirectoryObjectById_GetExpanded1.onOk(HttpResponseMessage responseMessage, Task1 response) at Microsoft.Graph.PowerShell.DirectoryObjects.DirectoryObjectsGetByIds1_Call(HttpRequestMessage request, Func3 onOk, Func3 onDefault, IEventListener eventListener, ISendAsync sender) at Microsoft.Graph.PowerShell.DirectoryObjects.DirectoryObjectsGetByIds1_Call(HttpRequestMessage request, Func3 onOk, Func3 onDefault, IEventListener eventListener, ISendAsync sender) at Microsoft.Graph.PowerShell.DirectoryObjects.DirectoryObjectsGetByIds1(IPathsG5Xp0HDirectoryobjectsMicrosoftGraphGetbyidsPostRequestbodyContentApplicationJsonSchema body, Func3 onOk, Func3 onDefault, IEventListener eventListener, ISendAsync sender) at Microsoft.Graph.PowerShell.Cmdlets.GetMgDirectoryObjectById_GetExpanded1.ProcessRecordAsync() at Microsoft.Graph.PowerShell.Cmdlets.GetMgDirectoryObjectById_GetExpanded1.ProcessRecordAsync()' Get-MgDirectoryObjectById_GetExpanded1: Unable to cast object of type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonObject' to type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonArray'. DEBUG: [CmdletEndProcessing]: - Get-MgDirectoryObjectById end processing.
Activity
peombwa commentedon Apr 7, 2021
Thanks for opening this bug. This is an issue with how delta response is described in our OpenAPI documents and is being tracked by https://github.com/microsoftgraph/microsoft-graph-devx-api/issues/307. I'll make a follow-up to see how far we are to having a fix.
[-]Object cast bug in Get-MgGroupDelta[/-][+]Object cast bug when calling OData actions and functions that return a collection.[/+]adamedx commentedon Jan 11, 2022
Peter Ombwa (@peombwa) , this seems to affect
Get-MgGroupMemberObjectfor instance which is a fairly common scenario. Is there an idea of the fix yet?pwouavre commentedon Mar 7, 2022
Hello Peter Ombwa (@peombwa),
Same issue using cmdlet "Get-MgDirectoryObjectById"
`
DEBUG: [CmdletBeginProcessing]: - Get-MgDirectoryObjectById begin processing with parameterSet 'GetExpanded1'.
DEBUG: [Authentication]: - AuthType: 'Delegated', AuthProviderType: 'InteractiveAuthenticationProvider', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph PowerShell'.
DEBUG: [Authentication]: - Scopes: [Application.Read.All, Application.ReadWrite.All, Directory.AccessAsUser.All, Directory.Read.All, Directory.ReadWrite.All, Group.Read.All, Group.ReadWrite.All, openid, profile, User.Read, User.Read.All, email].
Confirm
Are you sure you want to perform this action?
Performing the operation "Get-MgDirectoryObjectById_GetExpanded1" on target "Call remote 'DirectoryObjectsGetByIds1' operation".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Yes"):
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
POST
Absolute Uri:
https://graph.microsoft.com/v1.0/directoryObjects/microsoft.graph.getByIds
Headers:
SdkVersion : Graph-powershell-1.9.0,Graph-dotnet-1.25.1
FeatureFlag : 00000047
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.19042; fr-FR),PowerShell/2021.12.0,Get-MgDirectoryObjectById_GetExpanded1
Accept-Encoding : gzip
Body:
{
"ids": [
"b94bb396-409b-475b-9e8e-ba5346e01624"
]
}
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Transfer-Encoding : chunked
Location : https://graph.microsoft.com/
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : 4c00738c-875d-4d5f-a332-db6c5f662c49
client-request-id : 4c00738c-875d-4d5f-a332-db6c5f662c49
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"France Central","Slice":"E","Ring":"5","ScaleUnit":"000","RoleInstance":"PA1PEPF0004BC50"}}
x-ms-resource-unit : 3
OData-Version : 4.0
Date : Mon, 07 Mar 2022 15:17:49 GMT
Body:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects",
"value": [
{
"@odata.type": "#microsoft.graph.group",
"id": "b94bb396-409b-475b-9e8e-ba5346e01624",
"deletedDateTime": null,
"classification": null,
"createdDateTime": "2019-12-05T12:55:09Z",
"creationOptions": [],
"description": null,
"displayName": "GDO_SG_AZR-BIG-DBA",
"expirationDateTime": null,
"groupTypes": [],
"isAssignableToRole": null,
"mail": null,
"mailEnabled": false,
"mailNickname": "76a01287-1",
"membershipRule": null,
"membershipRuleProcessingState": null,
"onPremisesDomainName": null,
"onPremisesLastSyncDateTime": null,
"onPremisesNetBiosName": null,
"onPremisesSamAccountName": null,
"onPremisesSecurityIdentifier": null,
"onPremisesSyncEnabled": null,
"preferredDataLocation": null,
"preferredLanguage": null,
"proxyAddresses": [],
"renewedDateTime": "2019-12-05T12:55:09Z",
"resourceBehaviorOptions": [],
"resourceProvisioningOptions": [],
"securityEnabled": true,
"securityIdentifier": "S-1-12-1-3108746134-1197162651-1404735134-605478982",
"theme": null,
"visibility": null,
"onPremisesProvisioningErrors": []
}
]
}
DEBUG: [CmdletException]: Received exception with message 'InvalidCastException - Unable to cast object of type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonObject' to type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonArray'. : at Microsoft.Graph.PowerShell.Runtime.Json.JsonArray.Parse(String text)
at Microsoft.Graph.PowerShell.DirectoryObjects.<>c.<DirectoryObjectsGetByIds1_Call>b__59_0(Task
1 body) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Microsoft.Graph.PowerShell.Cmdlets.GetMgDirectoryObjectById_GetExpanded1.onOk(HttpResponseMessage responseMessage, Task
1 response) at Microsoft.Graph.PowerShell.DirectoryObjects.DirectoryObjectsGetByIds1_Call(HttpRequestMessage request, Func3 onOk, Func3 onDefault, IEventListener eventListener, ISendAsync sender) at Microsoft.Graph.PowerShell.DirectoryObjects.DirectoryObjectsGetByIds1_Call(HttpRequestMessage request, Func3 onOk, Func3 onDefault, IEventListener eventListener, ISendAsync sender) at Microsoft.Graph.PowerShell.DirectoryObjects.DirectoryObjectsGetByIds1(IPathsG5Xp0HDirectoryobjectsMicrosoftGraphGetbyidsPostRequestbodyContentApplicationJsonSchema body, Func3 onOk, Func3 onDefault, IEventListener eventListener, ISendAsync sender) at Microsoft.Graph.PowerShell.Cmdlets.GetMgDirectoryObjectById_GetExpanded1.ProcessRecordAsync() at Microsoft.Graph.PowerShell.Cmdlets.GetMgDirectoryObjectById_GetExpanded1.ProcessRecordAsync()' Get-MgDirectoryObjectById_GetExpanded1: Unable to cast object of type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonObject' to type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonArray'. DEBUG: [CmdletEndProcessing]: - Get-MgDirectoryObjectById end processing.