Created
March 16, 2017 17:22
-
-
Save esell/9e0f1b0b8f30904d88486a5e4d1d937a to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# get list of VMs | |
VMLIST=`azure vm list --json |jq '. | .[].name'` | |
for v in $VMLIST | |
do | |
v=`echo $v | sed 's/"//g'` | |
echo "looking up $v..." | |
# get RG | |
rg="$(azure vm list --json |jq '.[] | select( .name == "'"$(eval echo $v)"'") | .resourceGroupName')" | |
# get creation time zulu | |
creation="$(azure vm get-instance-view --json $(eval echo $rg) $(eval echo $v) |jq '. | .instanceView.statuses[0].time')" | |
echo "host: $v creation date: $creation resource group: $rg" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment