Created
June 1, 2018 14:23
-
-
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
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
# 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