-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Description
Get-AzADUser -UserPrincipalName "Brian.O'[email protected]"
returns
Az.MSGraph.internal\Get-AzADUser : Invalid filter clause
At C:\Users\...\Documents\WindowsPowerShell\Modules\Az.Resources\5.3.1\MSGraph.Autorest\custom\Get-AzADUser.ps1:210 char:9
+ Az.MSGraph.internal\Get-AzADUser @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ ConsistencyLe...= , Expand = }:<>f__AnonymousType3 7) [Get-AzADUser_List], Exception
+ FullyQualifiedErrorId : BadRequest,Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Cmdlets.GetAzADUser_List
If you run with the -Debug flag, you can see the issue is that the ' in the UPN is not URL encoded:
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method: GET
Absolute Uri: https://graph.microsoft.com/v1.0/users?$filter=userPrincipalName eq 'Brian.O'[email protected]'
Issue script & Debug output
Get-AzADUser -UserPrincipalName "Brian.O'[email protected]" -debug
DEBUG: [CmdletBeginProcessing]: Starting command
Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): A
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: Client side pagination is enabled for this cmdlet
DEBUG: [CmdletProcessRecordAsyncStart]: Created new QosEvent for command 'Get-AzADUser_List'
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /users?$filter=userPrincipalName%20eq%20'Brian.O'Brian%40example.com'
DEBUG: RequestCreated: /v1.0/users?$filter=userPrincipalName%20eq%20'Brian.O'Brian%40example.com'
DEBUG: HeaderParametersAdded:
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://graph.microsoft.com/v1.0/users?$filter=userPrincipalName eq 'Brian.O'Brian@example.com'
Headers:
x-ms-unique-id : 50
x-ms-client-request-id : eb00ad58-ce28-4283-9648-25dd9a3ea287
CommandName : Az.MSGraph.internal\Get-AzADUser
FullCommandName : Get-AzADUser_List
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v0.0.0,PSVersion/v5.1.22000.282,Az.MSGraph/5.3.1
Body:
DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
X-Bst-Request-Id : tcnjDj:QLT:586625
X-Bst-Info : t=1646411725,h=57j,p=80594_288:2_12078,u=928059197,c=2339,c=68955,v=7.11.200100.64
Strict-Transport-Security : max-age=31536000
request-id : 206d7f37-c933-4a55-b945-c6832a4444ab
client-request-id : 206d7f37-c933-4a55-b945-c6832a4444ab
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"UK South","Slice":"E","Ring":"3","ScaleUnit":"000","RoleInstance":"LN2PEPF00005FF1"}}
Connection : keep-alive
Date : Fri, 04 Mar 2022 16:35:24 GMT
Via : 1.1 hosted.websense 57j
Body:
{
"error": {
"code": "BadRequest",
"message": "Invalid filter clause",
"innerError": {
"date": "2022-03-04T16:35:25",
"request-id": "206d7f37-c933-4a55-b945-c6832a4444ab",
"client-request-id": "206d7f37-c933-4a55-b945-c6832a4444ab"
}
}
}
DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
Confirm
Invalid filter clause
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"):
Az.MSGraph.internal\Get-AzADUser : Invalid filter clause
At C:\Users\...\Documents\WindowsPowerShell\Modules\Az.Resources\5.3.1\MSGraph.Autorest\custom\Get-AzADUser.ps1:210 char:9
+ Az.MSGraph.internal\Get-AzADUser @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ ConsistencyLe...= , Expand = }:<>f__AnonymousType3`7) [Get-AzADUser_List], Exception
+ FullyQualifiedErrorId : BadRequest,Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Cmdlets.GetAzADUser_List
DEBUG: [Finally]: Getting exception 'Microsoft.Azure.Commands.Common.Exceptions.AzPSCloudException: InternalException' from response
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent: Module: Az.MSGraph:5.3.1; CommandName: Get-AzADUser_List; PSVersion: 5.1.22000.282; IsSuccess: False; Duration: 00:00:00; Exception: InternalException;
DEBUG: Finish sending metric.
DEBUG: CmdletEndProcessing:
Environment data
Name Value
---- -----
PSVersion 5.1.22000.282
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22000.282
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.7.2 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
Script 5.3.1 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}
Script 4.2.0 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountManagementPolicyAction, Add-AzStorageAccountNetworkRule, Close-AzStorageFileHandle...}
Manifest 2.1.0 AzTable {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}
Error output
Message : [BadRequest] : Invalid filter clause
StackTrace :
Exception : System.Exception
InvocationInfo : {Get-AzADUser_List}
Line : Az.MSGraph.internal\Get-AzADUser @PSBoundParameters
Position : At C:\Users\...\Documents\WindowsPowerShell\Modules\Az.Resources\5.3.1\MSGraph.Autorest\custom\Get-AzADUser.ps1:210 char:9
+ Az.MSGraph.internal\Get-AzADUser @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 100