VMware Cloud Community
emeteradmin
Contributor
Contributor

need "VRM Owner" to be a different value that "username" in the workflow

we have a need to change the field that gets created in vCenter to be the user's email address instead of the SAMaccountname (the email ID is different from this for reasons that is hard to explain)

We cannot identify users by the user id without having to look them up, so having the filed get populated in vcenter with a human readable filed would be most helpful

0 Kudos
1 Reply
kallischlauch
Enthusiast
Enthusiast

Hey,

maybe there are more elegant ways but I needed to retrieve email address from owner to be able to send email notifications.

I sent the samAccountName to a powershell host who retrieved and returned email address

the biggest problem here is actually to parse the result (powershell host sends object, not only the string with email address)

this is what I cooked up to parse the object and retrive the string from powershell host (heartbreaking)

===

jsonres=outputPS.getAsJson();

System.log("XML response:\n"+jsonres+"\n");

j2=JSON.parse(jsonres);

ReturnParameter=j2.Objs.Obj.LST.Obj[1].S;

System.log(returnParameter) 

===

Powershell code (yes -- its obvious -- i'm not a programmer) you can modify the filter is you feed samaccountname

## Accepts UPN as parameter and returns emailaddress

param(

     [string] $userPrincipalName

     )

[string] $emailAddress

Import-Module activedirectory

$filter= "userPrincipalName -eq '"+$userPrincipalName+"'"

$mailAddress= get-aduser -filter $filter -server <myGlobalCatalogServer>:3268 -properties emailaddress

$emailAddress= $mailAddress.EmailAddress

return $emailAddress

0 Kudos