I think I've asked this question before, but can't seem to find if there was ever a good solution.
Environment has ~40 vcenters. Some are linked, some are not.
I'm running a modified version of Alan and Luc's role/permission script from 2010. (yes, its still useful today!)
The problem is that when I log into a linked vcenter, it creates a role from each vcenter login. So I end up getting duplicate roles. When you later go to set permissions using 'the role', it fails because there's two.
So, the larger question is wondering if there is any way to tell that you're logged into a linked vcenter so that automation like this doesn't happen twice? Or is the only real solution to do a duplication check before role creation/whatever else you're trying to do?