VMware Cloud Community
SENNAF1
Enthusiast
Enthusiast

Designate a VM in Active Directory?

I am very new to VRA been using it and vRO for only a couple of weeks.  I am trying to come up with a way to designate a new request or a machine provisioned through vRA in MS Active Directory.   I have an application that will scan almost anything in AD OU, Attribute, Part of the name and import it into the application. I just need a way to designate it from the rest. 

We have discussed the following and keep getting roadblocks.

SCAN OU

In my blueprint I have a dropdown that lets the user select the OU to place the machine in.  So a new provisioned VM goes into a OU, but there are other computer accounts in that OU and I do not want all of them to be imported.

The only thing I can think of would be to have vRA add a custom attribute to the VM.  I do not even know how to start this.

Any help here would be greatly appreciated.

Shaft

Reply
0 Kudos
9 Replies
SENNAF1
Enthusiast
Enthusiast

Is there a way to add a Active Directory attributes to new machines added to AD by vRA?

Reply
0 Kudos
sbeaver
Leadership
Leadership

If I am understanding your question correctly, I believe you are looking to take some AD values and add them to a new provisioned machine, is that correct?  If so, I am doing something similar but using ServiceNow and values as what I add to a provisioned VM.  I have a workflow subscription that runs as the first workflow once a request is made that will do some processing with values presented in the request and then will update the vm be provisioned with the values that were just calculated. Actually take workflow populated 25 different values colllected during that stage so long story short, yes you can add AD values to the virtual machine.  One of the first things I would do to setup that process is to create a Property Group in the Property Dictionary for your AD values you are looking to populate.  For the name you can do something like this.... VirtualMachine.ActiveDirectory.DomainName.Attribute

Here is my template that I use to make updates

//var entity = virtualMachineEntity

System.log("Processing VM Information")

var virtualMachine = virtualMachineEntity.getInventoryObject();

if (virtualMachine == null)

{

    throw "The virtual machine ID is invalid";

}

var MachineProperties = new Properties();

var virtualMachinePropertyEntities = virtualMachineEntity.getLink(vCACHost, "VirtualMachineProperties");

for each (var virtualMachinePropertyEntity in virtualMachinePropertyEntities)

{

var propertyName = virtualMachinePropertyEntity.getProperty("PropertyName");

var propertyValue = virtualMachinePropertyEntity.getProperty("PropertyValue");

MachineProperties.put(propertyName, propertyValue);

      if (propertyName == "VirtualMachine.ActiveDirectory.DomainName.Attribute") {

           System.log("Found the droid we have been looking for")

      break;

      }

}

//Got info and ready to update entity

var vmUpdate =

{

"PropertyName" : "VirtualMachine.ActiveDirectory.DomainName.Attribute",

"PropertyValue" : Attribute

};

//var virtualMachineProperties = new Properties();

var model = "ManagementModelEntities.svc";

var entitySet = "VirtualMachineProperties";

var links = new Properties();

links.put("VirtualMachineProperties",virtualMachineEntity); //The property needs to link back to the blueprint

var entityKey = virtualMachinePropertyEntity.entityKey;

var entityKeyId = entityKey.get("Id");

  var entityUpdate = vCACEntityManager.updateModelEntityBySerializedKey(vCACHost.id , model , entitySet, entityKeyId , vmUser, links

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Reply
0 Kudos
SENNAF1
Enthusiast
Enthusiast

Thanks for the reply,  I think you understand but it is in reverse.   When the Active directory computer object is created (server joined to the domain) I want to add something somewhere in that computer object that says it is built from vRA.  this can be the description, an attribute site.  I just figured adding an attribute would be best.

Is this possible?

I have only 2 months experience with vRA so be gentleSmiley Happy

Ayrton Senna da Silva

Reply
0 Kudos
sbeaver
Leadership
Leadership

OK process in reverse.  I am not seeing any OOB workflow in my environment for adding custom values to the AD Object but I am willing to bet there is a few dozen or more powershell examples that can be used so you can encapsulate a powershell script in vRO to get the values needed and push the script to your powershell proxy.

I do see some event broker samples for AD in Library --> System --> vRealize Automation --> AD Integration that you might find something useful that you can use if you have that on your vRO

Making any sense or do we need to dive a little deeper?

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Reply
0 Kudos
SENNAF1
Enthusiast
Enthusiast

I understand what you are saying but not clear on the how.    What should I search google for or can you suggest a blog that would show these powershell examples.

The second half I can only assume you are looking in vRO for Library --> System --> vRealize Automation --> AD Integration.  I am on version 7.2 and all my AD workflows are under Library > Microsoft > Active Directory  I do not see anything that might help.

Thanks again for your help.

Reply
0 Kudos
sbeaver
Leadership
Leadership

First thing you will need is the powershell plugin and have a host added or you can use the Guest Script Manager -- Guest script manager package

Below is an example PowerShell script that I encapsulate into a scriptable task inside the vRO workflow and then in this example I sent the script to a pre-configured powershell host to run

var output;

var session;

PSscript = ''

+ '# Add the VMware base cmdlets\n'

+ 'Add-PSSnapin VMware.VimAutomation.Core\n'

+ '# This Snapin adds the VMware Update Manager cmdlets\n'

+ '# Add-PSSnapin VMware.VumAut0mation\n'

+ 'Connect-VIServer -server '+vCenter+' -user '+vcuser+' -password '+vcpass+'\n'

+ '$vms = Get-VM\n'

+ 'foreach ($vm in $vms) {\n'

+ '$mem = (Get-VM $vm | Select-Object -Property MemoryGB).MemoryGB\n'

+ '$cpu = (Get-VM $vm | Select-Object -Property numCPU).NumCpu\n'

+ 'write-host ""\n'

+ 'write-host "This $vm has $mem GB of memory and $cpu CPUs"\n'

+ 'If (($cpu -le 2) -and ($mem -le 8)) {\n'

+ '    Write-Host "$vm is a small vm"\n'

+ '    $vm |Set-CustomField -name "Service Offering" -Value small\n'

+ '    }\n'

+ 'elseif (($cpu -le 4) -and ($mem -le 16)) {\n'

+ '    Write-Host "$vm is a medium vm"\n'

+ '    $vm |Set-CustomField -name "Service Offering" -Value medium\n'

+ '    }\n'

+ 'elseif (($cpu -le 😎 -and ($mem -le 32)) {\n'

+ '    Write-Host "$vm is a large vm"\n'

+ '    $vm |Set-CustomField -name "Service Offering" -Value large\n'

+ '    }\n'

+ 'elseif (($cpu -gt 😎 -or ($mem -gt 32)) {\n'

+ '    Write-Host "$vm is a x-large vm"\n'

+ '    $vm |Set-CustomField -name "Service Offering" -Value xl\n'

+ '    }\n'

+ 'elseif (($cpu -gt 2) -and ($cpu -le 4) -or ($mem -gt 😎 -and ($mem -le 16)) {\n'

+ '    Write-Host "$vm is a medium vm"\n'

+ '    $vm |Set-CustomField -name "Service Offering" -Value medium\n'

+ '    }\n'

+ 'elseif (($cpu -gt 4) -and ($cpu -le 😎 -or ($mem -gt 16) -and ($mem -le 32)) {\n'

+ '    Write-Host "$vm is a large vm"\n'

+ '    $vm |Set-CustomField -name "Service Offering" -Value large\n'

+ '    }\n'

+ 'else {"$vm needs to be to further classified"}\n'

+ '}\n'

try {

               session = host.openSession();

               output = System.getModule("com.vmware.library.powershell").invokeScript(host,PSscript,session.getSessionId()) ;

} finally {

               if (session){

                              host.closeSession(session.getSessionId());

               }

}

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
SENNAF1
Enthusiast
Enthusiast

sbeaver, thanks for the replies.  I am going to take some time to respond so I can ingest all of this. 

For now I need to add this guest script manager plugin to vRO? 

Is there  a recommended way to backup vRO?  I am running it embedded on my vRA 7.2 appliance.  Can I just take a Veeam backup with the appliance running?  Will it restore successfully?

Thanks,

     SennaF1

Reply
0 Kudos
SENNAF1
Enthusiast
Enthusiast

sbeaver,  thanks for trying to help me with this,  as stated I am new to vRA and am still getting a grasp of things.  In the end this needed to be done quicker then I could learn so VMware was contracted to get this working. 

They built a custom workflow that created the custom properties on the blueprint.

Thanks again for your help. You did teach me how some of this works.

Reply
0 Kudos
sbeaver
Leadership
Leadership

SENNAF1,

Would it be possible for you to sterilize the workflow, package it up and share with the class?

Steve

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Reply
0 Kudos