All scripts
Governance 598

Get-PurviewSensitivityLabelReport

Reports every sensitivity label with its publish scope and protection settings, so a label that was created but never actually published to any policy gets caught.

Get-PurviewSensitivityLabelReport.ps1
<#
.SYNOPSIS
    Reports sensitivity labels and their publish status.

.DESCRIPTION
    Lists every sensitivity label along with whether it is included in a
    published label policy and its protection settings, so a label that
    was created but never actually published to users gets caught.

.EXAMPLE
    .\Get-PurviewSensitivityLabelReport.ps1

.NOTES
    Requires the ExchangeOnlineManagement module connected to Security &
    Compliance PowerShell (Connect-IPPSSession).

.AUTHOR
    Shehryar Hassan
#>

$labels = Get-Label
$policies = Get-LabelPolicy

$publishedLabelIds = $policies.Labels

$report = $labels | ForEach-Object {
    [pscustomobject]@{
        LabelName  = $_.DisplayName
        Published  = $_.ImmutableId -in $publishedLabelIds
        Encryption = [bool]$_.EncryptionEnabled
        ContentMarking = [bool]$_.ContentMarkingEnabled
    }
}

$report | Format-Table -AutoSize
$report | Where-Object { -not $_.Published } | ForEach-Object { Write-Warning "$($_.LabelName) is not published to any policy." }

Read it before you run it, and test in a safe tenant first.