There can be a couple of reasons for the hang.
You might want to add a Start-TRanscript and Stop-Transcript to you script.
That might show why it hangs (I suspect there might be a prompt of some kind).
That prompt could also be caused by the UAC.
Is UAC enabled or disabled on the target guest OS?