Quantcast
Channel: VMware Communities : All Content - vRealize Automation Tools
Viewing all articles
Browse latest Browse all 9859

Are you struggling to get the VM owners email address?

$
0
0

In my environment I was struggling a little to get the owners email address since the logon ID does not match the email address or even the correct domain so let my share what I have done and hopefully this might help someone else.

 

First off I get the Owner property and strip everything after the @ away which leaves me the login ID

 

ownerid = ownerName.split("@");

var ownerID = ownerid[0];

 

Now I have a powershell script to use WMI to get the email address but I was struggling to get this to work correct via vCO and the powershell plug in so I changed directions and uploaded the script to vCAC and used the designer to run the script on one of the workflowstubs and retrieve and store the email address of the user. See this post I used a guide http://cloudyautomation.com/2013/08/27/working-with-the-invoke-powershell-script-activity-in-vcac/

 

Below is the function I used to get the email address and what is loaded into vCAC

 

function GetEmail

{

$query = "Select * FROM ds_user where ds_sAMAccountName='$ownerID'"

$user = Get-WmiObject -Query $query -Namespace "root\Directory\LDAP"

$owner = $user.DS_mail

$Global:ownerEmail = "$owner"

}

GetEmail

 

Now I have the email address and have stored that value with the VM that I can call for any custom emails.

 

Cheers!!!


Viewing all articles
Browse latest Browse all 9859

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>