Edit

Share via


New-EntraNamedLocationPolicy

Creates a new named location policy in Microsoft Entra ID.

Syntax

Default (Default)

New-EntraNamedLocationPolicy

    [-OdataType <String>]
    [-Id <String>]
    [-DisplayName <String>]
    [-IpRanges <System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.IpRange]>]
    [-IsTrusted <Boolean>]
    [-CountriesAndRegions <System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.CountriesAndRegion]>]
    [-IncludeUnknownCountriesAndRegions <Boolean>]
    [<CommonParameters>]

Description

This cmdlet allows an admin to create new named location policy in Microsoft Entra ID.

Conditional access policies are custom rules that define an access scenario.

In delegated scenarios with work or school accounts, when acting on another user, the signed-in user must have a supported Microsoft Entra role or custom role with the required permissions. The least privileged roles for this operation are:

  • Security Administrator
  • Conditional Access Administrator

Examples

Example 1: Creates a new Ip named location policy in Microsoft Entra ID

Connect-Entra -Scopes 'Policy.ReadWrite.ConditionalAccess'
$ipRanges = New-Object -TypeName Microsoft.Open.MSGraph.Model.IpRange
$ipRanges.cidrAddress = '6.5.4.3/32'
$type = '#microsoft.graph.ipNamedLocation'
New-EntraNamedLocationPolicy -OdataType $type -DisplayName 'IP named location policy' -IsTrusted $false -IpRanges $ipRanges
Id                                   CreatedDateTime     DisplayName              ModifiedDateTime
--                                   ---------------     -----------              ----------------
bbbbbbbb-1111-2222-3333-cccccccccccc 31-07-2024 10:45:27 IP named location policy 31-07-2024 10:45:27

This command creates a new country named location policy in Microsoft Entra ID.

  • -OdataType parameter specifies the odata type of a named location policy.
  • -DisplayName parameter specifies the display name of a named location policy.
  • -IsTrusted parameter specifies the IsTrusted value for the named location policy.
  • -IpRanges parameter specifies List of IP address ranges in IPv4 CIDR format (e.g., 1.2.3.4/32) or any valid IPv6 format as specified in IETF RFC596.

Example 2: Creates a new country named location policy in Microsoft Entra ID

Connect-Entra -Scopes 'Policy.ReadWrite.ConditionalAccess'
$type = '#microsoft.graph.countryNamedLocation'
New-EntraNamedLocationPolicy -OdataType $type -DisplayName 'Country named location policy' -CountriesAndRegions 'IN' -IncludeUnknownCountriesAndRegions $false
Id                                   CreatedDateTime     DisplayName                   ModifiedDateTime
--                                   ---------------     -----------                   ----------------
cccccccc-2222-3333-4444-dddddddddddd 31-07-2024 10:46:16 Country named location policy 31-07-2024 10:46:16

This command creates a new country named location policy in Microsoft Entra ID.

  • -OdataType parameter specifies the odata type of a named location policy.
  • -DisplayName parameter specifies the display name of a named location policy.
  • -CountriesAndRegions parameter specifies the countries and regions for the named location policy.
  • -IncludeUnknownCountriesAndRegions parameter specifies the includeUnknownCountriesAndRegions value for the named location policy.

Parameters

-CountriesAndRegions

Specifies the countries and regions for the named location policy in Microsoft Entra ID. List of countries and/or regions in the two-letter format specified by ISO 3166-2.

Parameter properties

Type:

System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.CountriesAndRegion]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DisplayName

Specifies the display name of a named location policy in Microsoft Entra ID.

Parameter properties

Type:System.String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Id

Specifies the ID of a named location policy in Microsoft Entra ID.

Parameter properties

Type:System.String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IncludeUnknownCountriesAndRegions

Specifies the includeUnknownCountriesAndRegions value for the named location policy in Microsoft Entra ID.

Parameter properties

Type:System.Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IpRanges

List of IP address ranges in IPv4 CIDR format (e.g., 1.2.3.4/32) or any valid IPv6 format as specified in IETF RFC596. The @odata.type of the ipRange is also required.

Parameter properties

Type:

System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.IpRange]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-IsTrusted

Specifies the IsTrusted value for the named location policy in Microsoft Entra ID.

Parameter properties

Type:System.Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-OdataType

Specifies the OData type of a named location policy object in Microsoft Entra ID.

Parameter properties

Type:System.String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Notes