Изменить

Поделиться через


New-EntraNamedLocationPolicy

Creates a new named location policy in Microsoft Entra ID.

Syntax

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.

Type:System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.CountriesAndRegion]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DisplayName

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

Type:System.String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Id

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

Type:System.String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-IncludeUnknownCountriesAndRegions

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

Type:System.Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:System.Collections.Generic.List`1[Microsoft.Open.MSGraph.Model.IpRange]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-IsTrusted

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

Type:System.Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-OdataType

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

Type:System.String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Notes