Using PowerCLI SPBM cmdlets to create VMs with storage policy

Recently I was looking for a way to consume the Storage Policy Based Management (SPBM) cmdlets in PowerCLI. I wanted to see if I could provision a VM from a Template onto my vSAN datastore with a particular policy rather than simply change it after it was deployed. It wasn’t as easy as I thought, as some of the commands I tried would only change the VM Home Namespace to the new policy, and leave the disks with the default datastore policy. And when I tried to clone a new VM from a template, I couldn’t get the VM to…