Are you running the code in the bottom of your post and that is the code that is generating the error?
What version of ESX and PowerCLI?
You should be able to get the cause of issue , check hostd logs it will tell you what is the warning all about .
As in my case it was Invalid transition requested (VM_STATE_ON_SHUTTING_DOWN -> VM_STATE_CREATE_SNAPSHOT): Invalid state error , all i did was restarted management agent on host and vCenter Services executed task again to fix.
Yes, the code is on the bottom. This is ESXi v5.5 and PowerCLI 5.8 (Build 2057893)