You can do something like this.
In $entity store the object for which you want to query the permissions.
The output shows where the permission comes from.
$si = Get-View ServiceInstance
$authMgr = Get-View -Id $si.Content.AuthorizationManager
$inherited = $true
$entity = Get-VM -Name MyVM
$authMgr.RetrieveEntityPermissions($entity.ExtensionData.MoRef,$inherited) |
Select Principal,Group,Propagate,
@{N='Role';E={(Get-VIRole -Id $_.RoleId).Name}},
@{N='PermissionFrom';E={(Get-View -Id $_.Entity -Property Name).Name}}