All scripts
Governance 615

Get-AzureResourceLockReport

Lists every resource lock in the subscription with its scope and lock level, so a forgotten CanNotDelete lock does not cause confusion during a future cleanup or teardown.

Get-AzureResourceLockReport.ps1
<#
.SYNOPSIS
    Reports all resource locks across the subscription.

.DESCRIPTION
    Lists every resource lock with its scope, lock level, and notes
    field, so a forgotten CanNotDelete lock does not cause confusion
    during a future cleanup or teardown when a resource unexpectedly
    refuses to delete.

.EXAMPLE
    .\Get-AzureResourceLockReport.ps1

.NOTES
    Requires the Az.Resources module and an active Connect-AzAccount session.

.AUTHOR
    Shehryar Hassan
#>

$locks = Get-AzResourceLock

$report = $locks | Select-Object LockName, LockLevel, ResourceGroupName, ResourceName, Notes

$report | Format-Table -AutoSize
Write-Host "$($locks.Count) resource lock(s) found" -ForegroundColor Cyan

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