Created
January 30, 2017 03:12
-
-
Save RIKIKU/592ab1357d376c9d2a9a755fb2eef493 to your computer and use it in GitHub Desktop.
Remove expired SSL certificates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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