Skip to content

Instantly share code, notes, and snippets.

@ohthehugemanatee
Created March 6, 2018 11:01
Show Gist options
  • Save ohthehugemanatee/5cb0da5432568e31093cce06c4527e3e to your computer and use it in GitHub Desktop.
Save ohthehugemanatee/5cb0da5432568e31093cce06c4527e3e to your computer and use it in GitHub Desktop.
Bash script to start/stop an Azure remote workstation, and connect to it via RDP
#!/bin/bash
# Simple script to start/stop my Azure remote workstation.
# Requires:
# - Azure CLI configured
# - Remmina RDP client
# - Zenity
#
# Change these values to match your VM.
GROUP=WORKSTATION
MACHINE=win10work2
RDPCONFIG=~/.remmina/1518788004229.remmina
REMMINA=$(which remmina)
AZ=$(which az)
ZENITY=$(which zenity)
case "$1" in
start)
echo "Starting Azure workstation and connecting via RDP."
${AZ} vm start -g $GROUP -n $MACHINE |\
$ZENITY --progress --auto-kill --auto-close --pulsate --text="Starting Azure workstation" && \
${REMMINA} -c $RDPCONFIG
;;
stop)
echo "Shutting down Azure workstation and killing Remmina..."
${AZ} vm deallocate -g $GROUP -n $MACHINE |\
$ZENITY --progress --auto-kill --auto-close --pulsate --text="Shutting down Azure workstation" && \
${REMMINA} -q
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=false
Exec=/usr/local/bin/winvm stop
Name=Windows VM shutdown
Terminal=false
Categories=Application;X-Developer
MimeType=
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=false
Exec=/usr/local/bin/winvm start
Name=Windows VM start
Terminal=false
Categories=Application;X-Developer
MimeType=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment