Skip to content

Instantly share code, notes, and snippets.

@khorsmann
Created April 23, 2018 12:24
Show Gist options
  • Save khorsmann/7b68f0a7eb81d21e8f406a2d5d80fe83 to your computer and use it in GitHub Desktop.
Save khorsmann/7b68f0a7eb81d21e8f406a2d5d80fe83 to your computer and use it in GitHub Desktop.
#!/bin/sh
# /vmfs/volumes/datastore1/shutdown-all-vms.sh
shutdownmode=soft # could be soft,hard,force
VMLIST=`esxcli vm process list | grep "World ID" | cut -d \: -f2`
for config in ${VMLIST}
do
esxcli vm process kill --type=${shutdownmode} --world-id=${config}
done
sleep 2
echo "show esxcli vm process list"
esxcli vm process list
echo "enter maintenanceMode --enable true"
esxcli system maintenanceMode set --enable true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment