The New-MgIdentityConditionalAccessNamedLocation cmdlet is used to create named locations in Microsoft Entra ID (formerly Azure AD), which can then be referenced in conditional access policies. Named locations help admins define trusted IP ranges, country locations, or specific network boundaries from which users are allowed or restricted from signing in. By creating these trusted locations, you can strengthen security by enforcing policies. Examples include requiring multi-factor authentication when users sign in from outside corporate networks or blocking access from high-risk geographic regions.
This article shows you how to create a conditional access named location using both Microsoft Entra admin center and Microsoft Graph PowerShell:
Use the admin portal to define trusted IP ranges or countries for your policy controls.
You need the policy write permissions and the Graph module installed:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "Policy.ReadWrite.ConditionalAccess"
Run the script below by specifying the name and IP ranges or countries:
New-MgIdentityConditionalAccessNamedLocation -DisplayName -IpRanges
New-MgIdentityConditionalAccessNamedLocation -DisplayName "HQ Network" -IpRanges @(@{CidrAddress="10.0.0.0/24"})
New-MgIdentityConditionalAccessNamedLocation -DisplayName "Canada" -CountriesAndRegions @("CA")
New-MgIdentityConditionalAccessNamedLocation -DisplayName "Remote Sites" -IpRanges @(@{CidrAddress="192.168.0.0/16"}, @{CidrAddress="10.10.0.0/16"})
The following essential parameters can be used along with the New-MgIdentityConditionalAccessNamedLocation cmdlet:
| Parameter | Description |
|---|---|
| -DisplayName | Name for the named location (required). |
| -IpRanges | Array of objects specifying trusted IP ranges (CIDR notation). |
| -CountriesAndRegions | List of country codes for location. |
| -IsTrusted | Specifies whether this location is trusted. |
| -OdataType | Type discriminator for the object. |
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: