Private/Baselines/Get-HydrationTenantScopeTagId.ps1
|
function Get-HydrationTenantScopeTagId { <# .SYNOPSIS Returns the IDs of every Intune scope tag in the connected tenant .DESCRIPTION Internal helper function. Reads deviceManagement/roleScopeTags (requires DeviceManagementRBAC.Read.All) and fails closed when the built-in Default scope tag (0) is missing from the result, because that means the list is not the tenant's real one. #> [CmdletBinding()] [OutputType([string[]])] param() $tags = Get-GraphPagedResults -Uri 'beta/deviceManagement/roleScopeTags?$select=id,displayName' $ids = [string[]]@($tags | Where-Object { $null -ne $_ } | ForEach-Object { [string]$_.id }) if ($ids -notcontains '0') { throw 'The tenant scope tag list does not contain the built-in Default scope tag (0). Refusing to repair policies from an incomplete list.' } return $ids } |