Private/Get-NSPConditionalAccessOwnership.ps1
|
function Get-NSPConditionalAccessOwnership { <# .SYNOPSIS Reads the local ownership record: which live policy (by object ID) each definition owns in a tenant. .DESCRIPTION .nsp-conditionalaccess\ownership\<TenantId>.json: { "Policies": { "<DefinitionId>": { "ObjectId", "AppliedHash", "AppliedVersion", "AppliedAtUtc" } } } Written by the executor after each successful create, adopt, or update. Returns an empty map when no record exists yet. #> [CmdletBinding()] [OutputType([hashtable])] param( [Parameter(Mandatory)][string]$TenantId, [string]$ConfigRoot ) $owned = @{} $path = Join-Path (Get-NSPConditionalAccessLocalPath -Kind Ownership -ConfigRoot $ConfigRoot) "$TenantId.json" if (Test-Path -LiteralPath $path) { $record = Get-Content -LiteralPath $path -Raw | ConvertFrom-Json if ($record.Policies) { foreach ($entry in $record.Policies.PSObject.Properties) { $owned[$entry.Name] = $entry.Value } } } $owned } |