XCP-NG: How to shutdown all running domains (VMs) using the command line

This bash script will shut down all running domains (VMs) on an XCP-NG host using the command line:

for vm in $(xe vm-list power-state=running --minimal | tr ',' ' '); do
    xe vm-shutdown uuid=$vm
done

After that, you often want to force-shutdown all domains that are still running, which can be done with:

for vm in $(xe vm-list power-state=running --minimal | tr ',' ' '); do
    xe vm-shutdown uuid=$vm force=true
done