David Wang recently posted a great HOW TO for having a nightly script to run on guest machines and perform the following tasks:
- start / restore from saved state if machine is not running (preferably disconnected from network in order to preserve resources)
- run on the guest the VHD maintenance utility (manually done by mounting the ISO from the virtual server directory and pressing next on the guest)
- save state / ( shut down only if necessary for next stage)
- compact the VHD
Check out his HOW TO and script, here.