UCSD Create a TAG in vCenter for a given VM Name

Version 4
    Task NameCreating a TAG vCenter for a given VM
    Description
    Prerequisites
    1. Tested on 5.3.1.1
    CategoryWorkflow
    ComponentsvSphere 5.x
    User Inputs

    Instructions for Regular Workflow Use:

    1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
    2. Unzip the file on your computer. Should end up with a .WFD file.
    3. Log in to UCS Director as a user that has "system-admin" privileges.
    4. Navigate to "Policies-->Orchestration" and click on "Import".
    5. Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
    6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
    7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
    8. Click "Submit".
    9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment.

     

     

     

     

    The workflow:

     

    Screen Shot 2015-07-16 at 1.16.55 PM.png

     

    User input to the workflow:

     

    Screen Shot 2015-07-16 at 9.34.00 AM.png

     

    The workflow execution:

     

    Screen Shot 2015-07-16 at 1.13.15 PM.png

     

    The run time variables:

     

    Screen Shot 2015-07-16 at 1.13.37 PM.png

     

    The log file:

     

    Screen Shot 2015-07-16 at 1.13.01 PM.png

     

    Code section to set up file on target:

     

         echo 'param($vcent, $vmname, $vmtag)' > C:\\PowerCLICreateVMTAG.ps1

         echo 'Add-PSSnapin VMware.VimAutomation.Core' >> C:\\PowerCLICreateVMTAG.ps1

         echo 'Set-powercliconfiguration -InvalidCertificateAction ignore -Confirm: $false' >>  C:\\PowerCLICreateVMTAG.ps1

         echo 'Connect-viserver -server $vcent -protocol https -User root -Password vmware' >>  C:\\PowerCLICreateVMTAG.ps1

         echo 'Get-VM -Name $vmname | New-TagAssignment -TAG $vmtag -Confirm: $false' >> C:\\PowerCLICreateVMTAG.ps1

         echo 'Disconnect-VIServer -Server $vcent -Force -Confirm: $false' >> C:\\PowerCLICreateVMTAG.ps1

         echo 'exit 0' >> C:\\PowerCLICreateVMTAG.ps1

     

    Code section to execute the newly created file:

     

         C:\\PowerCLICreateVMTAG.ps1 ${vCenter} ${VM_Name} ${VM_TAG}| out-null

     

     

    ***Note***

     

         The command New-TagAssignment assumes that the tag does exist in vCenter. This does not create a new tag! It will however create a tag entry on a vm.

     

     

    The tags created during workflow executions:

     

    Screen Shot 2015-07-16 at 1.12.53 PM.png

     

    Screen Shot 2015-07-16 at 1.10.29 PM.png

     

    Some of the debugging by products on the PSA machine:

     

    Screen Shot 2015-07-16 at 9.22.24 AM.png

     

    Screen Shot 2015-07-16 at 9.22.02 AM.png