Just conquering this myself, so thought I would share.
It cannot be run from PXE.
The PC should be at the "Windows Login Screen" (i.e. no user logged in) for profile capture.
You should adjust your script to run outside of PXE, and then boot to PXE.