Description
Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:
- Make sure you can reproduce this issue using the latest released version of Microsoft.Graph or Microsoft.Graph.Beta.
- Please search the existing issues to see if there has been a similar issue filed.
- For issues related to authentication and service errors, please refer to our troubleshooting guide. For service issues, please open a question at https://developer.microsoft.com/graph/support.
Describe the bug
Can't use a variable on a filter for Get-MgDirectoryRole
To Reproduce
Steps to reproduce the behavior:
PS C:\Users\andreww> $role = "Global Administrator"
PS C:\Users\andreww> Get-MgDirectoryRole -Filter "DisplayName eq $role"
Get-MgDirectoryRole_List: Invalid filter clause: Syntax error at position 35 in 'DisplayName eq Global Administrator'.
Status: 400 (BadRequest)
ErrorCode: BadRequest
Date: 2023-07-31T10:29:37
Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : 1d8c6e96-bfc8-4bf4-8324-e00b9245a4de
client-request-id : 48247b71-88c4-4b45-ac5f-4a388c7fa5fb
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"Australia Southeast","Slice":"E","Ring":"4","ScaleUnit":"001","RoleInstance":"ML1PEPF00004AF4"}}
Date : Mon, 31 Jul 2023 10:29:36 GMT
Expected behavior
Returns details of role
Debug Output
Run the problematic command with
-Debug
and paste the resulting debug stream below.
⚠ ATTENTION: Be sure to remove any sensitive information that may be in the logs.
PS C:\Users\andreww> Get-MgDirectoryRole -Filter "DisplayName eq $role" -debug
DEBUG: [CmdletBeginProcessing]: - Get-MgDirectoryRole begin processing with parameterSet 'List'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.
DEBUG: [Authentication]: - Scopes: [AccessReview.Read.All, AdministrativeUnit.Read.All, Analytics.Read, AppCatalog.Read.All, Application.Read.All, Application.ReadWrite.All, AuditLog.Read.All, Directory.Read.All, Group.Read.All, openid, People.Read.All, profile, Sites.Read.All, User.Read, User.Read.All, User.ReadWrite.All, email, SecurityEvents.Read.All].
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://graph.microsoft.com/v1.0/directoryRoles?$filter=DisplayName eq Global Administrator
Headers:
FeatureFlag : 00000043
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.25915; en-AU),PowerShell/7.3.6
Accept-Encoding : gzip
SdkVersion : graph-powershell/2.1.0
client-request-id : 2fa7a2e3-19b8-4fb2-88c6-feab3bc7e966
Body:
Module Version
Please run
Get-Module Microsoft.Graph*
after cmdlet execution and paste the output below.
If a module cannot be installed or imported, please runGet-Module -ListAvailable
and paste the output.
PS C:\Users\andreww> Get-Module Microsoft.Graph*
ModuleType Version PreRelease Name ExportedCommands
Script 2.1.0 Microsoft.Graph.Applications {Add-MgApplicationKey, Add-MgApplicationPassword,…
Script 2.1.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-M…
Script 2.1.0 Microsoft.Graph.Identity.Directory… {Confirm-MgContactMemberGroup, Confirm-MgContactM…
Script 2.1.0 Microsoft.Graph.Security {Add-MgSecurityCaseEdiscoveryCaseCustodianHold, A…
Environment Data
Please run
$PSVersionTable
and paste the output below. If running the Docker container image, indicate the tag of the image used and the version of Docker engine.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.