Skip to content

Instantly share code, notes, and snippets.

@esell
Created March 16, 2017 17:22
Show Gist options
  • Save esell/9e0f1b0b8f30904d88486a5e4d1d937a to your computer and use it in GitHub Desktop.
Save esell/9e0f1b0b8f30904d88486a5e4d1d937a to your computer and use it in GitHub Desktop.
#!/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