How to get Entra ID conditional access named locations using Microsoft Graph PowerShell

The Get-MgIdentityConditionalAccessNamedLocation cmdlet retrieves named locations defined for conditional access in Microsoft Entra ID (previously Azure AD). Named locations help you specify trusted IP ranges or countries for use in security policies.

Get conditional access named locations using Microsoft Graph PowerShell

Prerequisites

  • Before using the cmdlet, ensure that the Microsoft Graph PowerShell module is installed. If not, install it using this PowerShell script:
    Install-Module Microsoft.Graph -Scope CurrentUser
  • Also, use the following PowerShell command to connect to Microsoft Graph with the required permissions (e.g., Policy.Read.All):
    Connect-MgGraph -Scopes "Policy.Read.All"

Using the Get-MgIdentityConditionalAccessNamedLocation cmdlet

Run the Graph PowerShell command below to list all named locations used in conditional access. This retrieves all named locations defined in your tenant:

Get-MgIdentityConditionalAccessNamedLocation

Examples

Example 1: Get details of a specific named location by ID

This Graph PowerShell command displays detailed information for a specific location:

Get-MgIdentityConditionalAccessNamedLocation -NamedLocationId "location-id"

Example 2: Show only country and displayName properties

This Graph PowerShell command command filters to show only the country and displayName properties for all named locations:

Get-MgIdentityConditionalAccessNamedLocation | Select-Object displayName, countriesAndRegions

Supported parameters

The following are some essential parameters that can be used along with the Get-MgIdentityConditionalAccessNamedLocation command:

Parameters Description
-NamedLocationId The unique ID of a specific named location
-Top Limits the number of results
-Filter Returns only locations matching a specified filter
-All Retrieves all results without paging
-Property Specifies properties to display

Limitations of using Microsoft Graph PowerShell to get conditional access named locations

  • PowerShell commands can get complicated with different use cases and scenarios.
  • IT admins can spend a lot of time debugging errors, which in turn negatively impacts productivity.
  • Delegation can get tricky since technicians require elevated permissions.

How ADManager Plus helps you manage Microsoft Entra ID

ADManager Plus, an identity governance and administration solution with comprehensive Microsoft Entra ID management and reporting capabilities, simplifies complex admin tasks from a single, user-friendly console:

Perform script-free Microsoft Entra ID management and reporting with ADManager Plus

 
  • Get conditional access named locations using Microsoft Graph PowerShell
  • Examples
  • Supported parameters
  • Limitations of using Microsoft Graph PowerShell to get conditional access named locations
  • How ADManager Plus helps you manage Microsoft Entra ID
The one-stop solution to Active Directory Management and Reporting
Email Download Link Email the ADManager Plus download link