First, thank you for putting this into a module.
That being said, I'm running this against a Standalone ESXi 4.1 host and am getting Invalid VIObject on every entity I try. I've also tried running this against a test folder in Vcenter with same results.
Image may be NSFW.
Clik here to view.
I try to pull in the name of the VM I want to assign permissions to into a variable. I ran get-folder to read the system names for the folders, trying to see if I can even assign a permission at root. ha-folder-root doesn't work, Folder-ha-folder-root doesn't work and putting them in a variable doesn't work either.
I have come to the conclusion the variable name I am using is correct. I've been able to reference similar context against a folder in VCenter using New-VIPermission, so it seems to me there is an issue with this module.