[GH-ISSUE #2134] [Feature Request]: Ability to have a Named Location Template for CA to mass deploy to clients. #1092

Closed
opened 2026-03-02 13:41:31 +03:00 by kerem · 1 comment
Owner

Originally created by @netprimates on GitHub (Feb 15, 2024).
Original GitHub issue: https://github.com/KelvinTegelaar/CIPP/issues/2134

Description of the new feature - must be an in-depth explanation of the feature you want, reasoning why, and the added benefits for MSPs as a whole.

Under CA we have the ability to have CA Templates but not for named locations. It would be great to have the ability to create Named Locations Template

Powershell Command below is how to create the Named Locations

PowerShell commands you would normally use to achieve above request

Write-Host -ForegroundColor $systemmessagecolor "NP187 Configure Conditional Access Policy"

###############################################################################

Script Settings

###############################################################################

$NamedLocation2 = "Allow - NP Pre-approved Locations (UK,IE,FR,DE,ES,US,CA,IT,BE,NL.CH,AT)"
$NamedLocation3 = "Allow - Travel Pass Locations"
$NamedLocation4 = "Office"

$ConditionalAccessName1 = "NP187 Block All except Trusted Named Locations"
$ConditionalAccessName2 = "NP187 Require MFA excluding Net Primates Office"

###############################################################################

Checking and Creating Named Locations within the Azure Platform

###############################################################################

Write-Host -ForegroundColor $systemmessagecolor "Checking and Creating Named Locations within the Azure Platform"
Write-Host "`n"

###############################################################################

Adds Allow - NP Pre-approved Locations (UK,IE,FR,DE,ES,US,CA,IT,BE,NL.CH,AT)

###############################################################################

if (Get-AzureADMSNamedLocationPolicy | where DisplayName -eq $NamedLocation2)
    {
    	Write-Host -ForegroundColor $processmessagecolor $NamedLocation2 "Found moving on"
    }
Else
    {
        New-AzureADMSNamedLocationPolicy -OdataType "#microsoft.graph.countryNamedLocation" -DisplayName $NamedLocation2 -CountriesAndRegions "GB","IE","FR","DE","ES","US","CA","IT","BE","NL","CH","AT" -IncludeUnknownCountriesAndRegions $false
        Write-Host -ForegroundColor $processmessagecolor $NamedLocation2 "now created"
    }

###############################################################################

Adds Travel Pass Named Location (UK Needs to be applied)

###############################################################################

if (Get-AzureADMSNamedLocationPolicy | where DisplayName -eq $NamedLocation3)
    {
    	Write-Host -ForegroundColor $processmessagecolor $NamedLocation3 "Found moving on"
    }
Else
    {
        New-AzureADMSNamedLocationPolicy -OdataType "#microsoft.graph.countryNamedLocation" -DisplayName $NamedLocation3 -CountriesAndRegions "GB" -IncludeUnknownCountriesAndRegions $false
        Write-Host -ForegroundColor $processmessagecolor $NamedLocation3 "now created"
    }

###############################################################################

Adds Office Named Location

###############################################################################

if (Get-AzureADMSNamedLocationPolicy | where DisplayName -eq $NamedLocation4)
    {
    	Write-Host -ForegroundColor $processmessagecolor $NamedLocation4 "Named Location now created Found moving on"
    }
Else
    {
        New-AzureADMSNamedLocationPolicy -OdataType "#microsoft.graph.ipNamedLocation" -DisplayName $NamedLocation4 -IsTrusted $true -IpRanges "***.*.***.***/**","***.*.***.***/**","**.**.**.**/**"
        Write-Host -ForegroundColor $processmessagecolor $NamedLocation4 "Named Location now created"
    }
Originally created by @netprimates on GitHub (Feb 15, 2024). Original GitHub issue: https://github.com/KelvinTegelaar/CIPP/issues/2134 ### Description of the new feature - must be an in-depth explanation of the feature you want, reasoning why, and the added benefits for MSPs as a whole. Under CA we have the ability to have CA Templates but not for named locations. It would be great to have the ability to create Named Locations Template Powershell Command below is how to create the Named Locations ### PowerShell commands you would normally use to achieve above request Write-Host -ForegroundColor $systemmessagecolor "NP187 Configure Conditional Access Policy" ############################################################################### # Script Settings ############################################################################### $NamedLocation2 = "Allow - NP Pre-approved Locations (UK,IE,FR,DE,ES,US,CA,IT,BE,NL.CH,AT)" $NamedLocation3 = "Allow - Travel Pass Locations" $NamedLocation4 = "Office" $ConditionalAccessName1 = "NP187 Block All except Trusted Named Locations" $ConditionalAccessName2 = "NP187 Require MFA excluding Net Primates Office" ############################################################################### # Checking and Creating Named Locations within the Azure Platform ############################################################################### Write-Host -ForegroundColor $systemmessagecolor "Checking and Creating Named Locations within the Azure Platform" Write-Host "`n" ############################################################################### # Adds Allow - NP Pre-approved Locations (UK,IE,FR,DE,ES,US,CA,IT,BE,NL.CH,AT) ############################################################################### if (Get-AzureADMSNamedLocationPolicy | where DisplayName -eq $NamedLocation2) { Write-Host -ForegroundColor $processmessagecolor $NamedLocation2 "Found moving on" } Else { New-AzureADMSNamedLocationPolicy -OdataType "#microsoft.graph.countryNamedLocation" -DisplayName $NamedLocation2 -CountriesAndRegions "GB","IE","FR","DE","ES","US","CA","IT","BE","NL","CH","AT" -IncludeUnknownCountriesAndRegions $false Write-Host -ForegroundColor $processmessagecolor $NamedLocation2 "now created" } ############################################################################### # Adds Travel Pass Named Location (UK Needs to be applied) ############################################################################### if (Get-AzureADMSNamedLocationPolicy | where DisplayName -eq $NamedLocation3) { Write-Host -ForegroundColor $processmessagecolor $NamedLocation3 "Found moving on" } Else { New-AzureADMSNamedLocationPolicy -OdataType "#microsoft.graph.countryNamedLocation" -DisplayName $NamedLocation3 -CountriesAndRegions "GB" -IncludeUnknownCountriesAndRegions $false Write-Host -ForegroundColor $processmessagecolor $NamedLocation3 "now created" } ############################################################################### # Adds Office Named Location ############################################################################### if (Get-AzureADMSNamedLocationPolicy | where DisplayName -eq $NamedLocation4) { Write-Host -ForegroundColor $processmessagecolor $NamedLocation4 "Named Location now created Found moving on" } Else { New-AzureADMSNamedLocationPolicy -OdataType "#microsoft.graph.ipNamedLocation" -DisplayName $NamedLocation4 -IsTrusted $true -IpRanges "***.*.***.***/**","***.*.***.***/**","**.**.**.**/**" Write-Host -ForegroundColor $processmessagecolor $NamedLocation4 "Named Location now created" }
kerem 2026-03-02 13:41:31 +03:00
Author
Owner

@KelvinTegelaar commented on GitHub (Feb 15, 2024):

Already in the product, make a ca tenplate that relies on a named location and it'll create the named location first.

<!-- gh-comment-id:1945720838 --> @KelvinTegelaar commented on GitHub (Feb 15, 2024): Already in the product, make a ca tenplate that relies on a named location and it'll create the named location first.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/CIPP#1092
No description provided.