Repository navigation
Description
I appear to have an issue with using 1.0.1 on PS5.1 where various cmdlets do not appear to work.
I've just found this module and only started using it today, so I am not sure of the extent of it's failure. However, some basic commands do not work, for example:
PS C:\Users> Get-MgUser -Top 10 -Property Id, DisplayName, BusinessPhones | Format-Table Id, DisplayName, BusinessPhones
Get-MgUser : Unrecognized query argument specified: '?$top'.
At line:1 char:1
+ Get-MgUser -Top 10 -Property Id, DisplayName, BusinessPhones | Format ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ Top = 10, Ski...ndProperty = }:<>f__AnonymousType43`8) [Get-MgUser_List1], RestException`1
+ FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.PowerShell.Cmdlets.GetMgUser_List1
Debug output for this command:
PS C:\Users> Get-MgUser -Top 10 -Property Id, DisplayName, BusinessPhones -Debug | Format-Table Id, DisplayName, BusinessPhones
DEBUG: CmdletBeginProcessing:
Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: https://graph.microsoft.com/v1.0/users?$top=10&Select=Id,DisplayName,BusinessPhones
DEBUG: RequestCreated: https://graph.microsoft.com/v1.0/users?$top=10&Select=Id,DisplayName,BusinessPhones
DEBUG: HeaderParametersAdded: https://graph.microsoft.com/v1.0/users?$top=10&Select=Id,DisplayName,BusinessPhones
DEBUG: GET /v1.0/users?$top=10&Select=Id%2CDisplayName%2CBusinessPhones HTTP/1.1
HTTP: graph.microsoft.com
DEBUG: BeforeCall:
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
Confirm
Unrecognized query argument specified: '?$top'.
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
Get-MgUser : Unrecognized query argument specified: '?$top'.
At line:1 char:1
+ Get-MgUser -Top 10 -Property Id, DisplayName, BusinessPhones -Debug | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ Top = 10, Ski...ndProperty = }:<>f__AnonymousType43`8) [Get-MgUser_List1], RestException`1
+ FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.PowerShell.Cmdlets.GetMgUser_List1
DEBUG: HTTP/1.1 400 Bad Request
request-id: c856109a-612c-46b2-8792-a49ff5f0c35c
client-request-id: c856109a-612c-46b2-8792-a49ff5f0c35c
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"North Central US","Slice":"SliceC","Ring":"3","ScaleUnit":"002","RoleInstance":"AGSFE_IN_30"}}
Strict-Transport-Security: max-age=31536000
Cache-Control: private
Date: Tue, 29 Sep 2020 15:24:47 GMT
Content-Length: 319
Content-Type: application/json
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: CmdletEndProcessing:
I also noticed a similar issue with attempting to query a user, but get more properties returned outside of the defaults (actual results changed to hide PPI):
PS C:\Users> Get-MgUser -UserId 0000-0000-000-0000
Id DisplayName Mail UserPrincipalName UserType
-- ----------- ---- ----------------- --------
0000-0000-0000-0000 John Smith jsmith@example.com jsmith@example.com
PS C:\Users> Get-MgUser -UserId 0000-0000-0000-0000 -Property Id,mail,accountEnabled -Debug
DEBUG: CmdletBeginProcessing:
Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): A
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: https://graph.microsoft.com/v1.0/users/0000-0000-0000-0000?Select=Id,mail,accountEnabled
DEBUG: RequestCreated: https://graph.microsoft.com/v1.0/users/0000-0000-0000-0000?Select=Id,mail,accountEnabled
DEBUG: HeaderParametersAdded: https://graph.microsoft.com/v1.0/users/0000-0000-0000-0000?Select=Id,mail,accountEnabled
DEBUG: GET /v1.0/users/0000-0000-0000-0000?Select=Id%2Cmail%2CaccountEnabled HTTP/1.1
HTTP: graph.microsoft.com
DEBUG: BeforeCall:
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
Confirm
Unrecognized query argument specified: '?$Select'.
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): A
Get-MgUser : Unrecognized query argument specified: '?$Select'.
At line:1 char:1
+ Get-MgUser -UserId 0000-0000-0000-0000 -Property Id, ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ UserId = 0000...ndProperty = }:<>f__AnonymousType7`3) [Get-MgUser_Get], RestException`1
+ FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.PowerShell.Cmdlets.GetMgUser_Get
DEBUG: HTTP/1.1 400 Bad Request
request-id: 0000-0000-0000-0000
client-request-id: 0000-0000-0000-0000
Strict-Transport-Security: max-age=31536000
Cache-Control: private
Date: Tue, 29 Sep 2020 15:29:38 GMT
Content-Length: 322
Content-Type: application/json
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: CmdletEndProcessing:
PS C:\Users>
edit: I find it interesting that the URL Created is actually invalid as it says ?Select and not ?$Select, but the error shows ?$Select being used. I've copied/pasted the URL into Graph Explorer and verified that it does not work but works if I add the $.
I installed PowerShell 7 on my device, and the module and they all work as they should. The issue only appears when running them in PS5.1. I thought it may be an incompatibility with the AzureAD modules I had installed, so I removed them all, but the issue persisted.
PS C:\Users> echo $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.1432
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1432
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Let me know if you need any further information.
Activity
peombwa commentedon Sep 30, 2020
aryxton, thanks for reporting this bug.
We've traced the issue to the underlaying .NET 4.x framework, and it only happens in PS 5.1. Consider using PS 7 as we work on getting a fix out via #410 .
aryxton commentedon Sep 30, 2020
I sadly can not use PS7 in this specific case. Looking forward to the fixed release.
Really appreciate everything you fellas do.
peombwa commentedon Oct 27, 2020
This has been fixed in 1.1.0.
Update-Module Microsoft.Graph.