Recently we had an issue with a user which when they tried to view a vCAC machine on the Items page and it would not completely load. Only a couple action items would appear. The machine information, storage, networking, properties and Snapshots tabs were not visible. By accident, while looking into vCAC machine ownership change via vCO, I discovered how to remove a user entity. We tried this and it solved the user's problems.
Inputs: ADUser (AD:User), vCACHost (vCAC:VCACHost)
var Owner = ADUser.userPrincipalName;
System.log("Owner: " + Owner);
var modelName = 'ManagementModelEntities.svc';
var entitySetName = 'Users';
var headers = null;
var properties = new Properties();
var entity = vCACEntityManager.readModelEntitiesByCustomFilter(vCACHost.id, modelName, entitySetName, properties, headers);
var entityID = null;
var i=0;
for each (var item in entity){
if(Owner == entity[i].properties.get("UserName")) {
entityID = i;
}
System.log("User Name - " + entity[i].properties.get("UserName"));
//System.log("User Name - " + entity[i].properties);
//System.log(i);
++i;
}
if (entityID != null) {
var updateEntity = entity[entityID];
//Will delete entity////////////////////////////////Will delete entity////////////////////////////////Will delete entity///////////////////////
var updated = vCACEntityManager.deleteModelEntityBySerializedKey(vCACHost.id, modelName, entitySetName, updateEntity.keyString, headers);
System.log("Removed User Entity");
}
else {
System.log("User Not Found");
}
This worked for our situation in a testing environment. Use at your own risk.