Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rcabr/f333eb922ad79b71bd6cd913dfde8e99 to your computer and use it in GitHub Desktop.
Save rcabr/f333eb922ad79b71bd6cd913dfde8e99 to your computer and use it in GitHub Desktop.
Azure PowerShell statement to find the earliest deployment in each resource group in a subscription
# Assumes the Azure RM context is already set (logged in, subscription selected).
# Returns a list of Resource Group Names and the Earliest Timestamp (from deployment activity) for each.
((Get-AzureRmResourceGroup | Select-Object ResourceGroupName) | Get-AzureRmResourceGroupDeployment)`
| Select-Object ResourceGroupName, @{Name="Created"; Expression = {$_.Timestamp}} `
| Sort-Object ResourceGroupName, Created `
| Group-Object ResourceGroupName `
| Select-Object Name, @{Name="EarliestTimestamp"; Expression={`
$_.Group.Created | Measure-Object -Minimum | Select-Object -ExpandProperty Minimum `
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment