Public/Remove-NSPConditionalAccessHomeCountryGroup.ps1
|
function Remove-NSPConditionalAccessHomeCountryGroup { <# .SYNOPSIS Requests reviewed retirement of a permanent home country group, offline. .DESCRIPTION The next deployment removes its baseline exemption first. Re-plan after that run to delete the home policy and forget the entry. Existing groups and memberships are kept. .EXAMPLE Remove-NSPConditionalAccessHomeCountryGroup -TenantProfile $profilePath -Key '01' #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)][string]$TenantProfile, [Parameter(Mandatory)][ValidatePattern('^\d{2}$')][string]$Key ) $content = Get-Content -LiteralPath $TenantProfile -Raw | ConvertFrom-Json $entry = Get-NSPConditionalAccessMapValue (Get-NSPConditionalAccessMapValue $content 'HomeCountryGroups') $Key if (-not $entry) { throw "No home country group '$Key' exists." } $entry | Add-Member -NotePropertyName RetireRequested -NotePropertyValue $true -Force if ($PSCmdlet.ShouldProcess($TenantProfile, "Request retirement of home country group $Key")) { Save-NSPConditionalAccessJson $content -Path $TenantProfile } Get-NSPConditionalAccessHomeCountryGroup $content | Where-Object Key -eq $Key } |