Skip to content

Instantly share code, notes, and snippets.

@OguzPastirmaci
Last active September 7, 2017 09:17
Show Gist options
  • Save OguzPastirmaci/eb79cf9f93827a3a2322 to your computer and use it in GitHub Desktop.
Save OguzPastirmaci/eb79cf9f93827a3a2322 to your computer and use it in GitHub Desktop.
Bash script that shows a menu to start or stop VMs using Azure cross-platfom CLI
#!/bin/bash
clear
echo ""
echo "-----------------------------------"
echo ""
echo "WHAT DO YOU WANT TO DO TODAY?"
echo ""
echo "1 - Start all the VMs"
echo "2 - Shutdown all the VMs"
echo ""
echo "0 - Exit"
echo ""
echo "-----------------------------------"
echo ""
echo -n "Enter selection: "
read selection
echo ""
case $selection in
1) azure vm list | grep "Stopped" | awk '{system("azure vm start "$2)}' ;;
2) azure vm list | grep "ReadyRole" | awk '{system("azure vm shutdown "$2)}' ;;
0) exit ;;
*) echo "Please enter 1, 2, or 0"
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment