Thanks for the reply Chris. Previous one was a Windows Based VC Server (vSphere 5.1). Here is the example of permissions :
| VM Name | Permission |
|---|---|
| VM1 | domain-name\user1; domain-name\user2; domain-name\user3 |
| VM2 | domain-name\user2 |
| VM3 | domain-name\user3; domain-name\user4 |
Now if I want to add permission for vm2, I am trying to read the XL :
$vm = get-vm VM2
$per = $worksheet.cells.item($intRow,1).value2
$vm | New-VIPermission -Role 'vm-user' -Principal $per -Propagate:$true
and that's where problem start. domain-name is our default domain.
However if I directly put domain-name\user2 in GUI in user field, I can add user. But if I write user2 and select identity source from dropdown I hit with the error that Call "UserDirectory.RetrieveUserGroups" for object "UserDirectory" on vCenter Server "VC Server Name" failed.
In case of PowerCLi error message is :
New-VIPermission : 10/27/2015 4:32:46 PM New-VIPermission Could not find VIAccount with name 'domain-name\user2'
New-VIPermission : 10/27/2015 4:32:47 PM New-VIPermission Value cannot be found for the mandatory parameter Principal