All scripts
Azure AI 141
Get-AzureBlobLifecyclePolicyReport
Reports the blob lifecycle management policy configured on every storage account, flagging accounts with no lifecycle rules at all, where old data likely sits at full price forever.
Get-AzureBlobLifecyclePolicyReport.ps1
<#
.SYNOPSIS
Reports blob lifecycle management policies across storage accounts.
.DESCRIPTION
Checks every storage account for a configured blob lifecycle
management policy and flags accounts with none, since without one,
old and rarely accessed data sits in the most expensive access tier
indefinitely.
.EXAMPLE
.\Get-AzureBlobLifecyclePolicyReport.ps1
.NOTES
Requires the Az.Storage module and an active Connect-AzAccount session.
.AUTHOR
Shehryar Hassan
#>
$accounts = Get-AzStorageAccount
$report = foreach ($account in $accounts) {
$policy = Get-AzStorageAccountManagementPolicy -ResourceGroupName $account.ResourceGroupName -StorageAccountName $account.StorageAccountName -ErrorAction SilentlyContinue
[pscustomobject]@{
StorageAccountName = $account.StorageAccountName
HasLifecyclePolicy = [bool]$policy
RuleCount = if ($policy) { $policy.Policy.Rules.Count } else { 0 }
}
}
$report | Format-Table -AutoSize
$report | Where-Object { -not $_.HasLifecyclePolicy } | ForEach-Object { Write-Warning "$($_.StorageAccountName) has no lifecycle policy." }
Read it before you run it, and test in a safe tenant first.