Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Remove expired SSL certificates
Login-AzureRmAccount -TenantId "InsertTennantIdHere"
Get-AzureRmSubscription -SubscriptionId "InsertSubscriptionIdHere" | Select-AzureRmSubscription
$certificates = Get-AzureRmResource -ExpandProperties | where ResourceType -EQ Microsoft.Web/certificates #This part takes ages to run.
foreach ($certificate in $certificates)
if((get-date $certificate.Properties.expirationDate) -le (Get-Date) )
Remove-AzureRmResource -ResourceName $certificate.ResourceName -ResourceType $certificate.ResourceType -ResourceGroupName $certificate.ResourceGroupName -Verbose -Confirm:$false -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment