VMware Aria Automation Tools

 View Only

 Using Rename virtual machine name workflow from another workflow

aardis's profile image
aardis posted May 01, 2025 02:44 PM

I'm trying to use the Rename virtual machine (And Rename virtual machine folder) workflow at the end of my other automation workflows to have the VM name in vcenter slightly different from the DNS name of the OS(appending -vm to it).  Any thoughts on how to pass the vm input (name) into the workflow from a scriptable task within another workflow so it picks up the vm as VC:Virtual Machine and will execute the rename_Task that is called from the rename workflow?  Add a workflow element for this adds the inputs but I'm struggling with how to pass these inputs from the previous task.  Would rather do it this way vs either a manual run or adding another task to do a powerCLI command if possible.

MohammadHadi Milani's profile image
MohammadHadi Milani

As I get, you need to rename vCenter VMs to its original name (hostname) to a string like hostname-VM. so
If you’d like to create a PowerCLI script to handle this, here’s a good starting point:

powershell
Connect-VIServer -Server vcenter.example.com
# Retrieve VMs that do not have "-VM" at the end of their name
# Try the following line first; if it doesn't work, use -notlike instead
$vms = Get-VM | Where-Object { $_.Name -notmatch "-vm$" }
foreach ($vm in $vms) {
    $vmName = $vm.Name
    $newName = "$($vm.Name)-VM"
    Set-VM -VM $vm -Name $newName -Confirm:$false
}
Disconnect-VIServer -Server * -Confirm:$false

# And always be careful when running a script in a production environment. (first test it in a lab environment)
You can run this script on a Windows workstation with PowerCLI installed, or you can integrate it into a vRO workflow using PowerShell host integration.

However, if you prefer to continue using the Rename Virtual Machine workflow in vRO, you’ll need to plan carefully. You should also add logic at the beginning of your script (or workflow) to fetch all VMs from vCenter that don’t already have -vm at the end of their name.

If you want to proceed with this method, I’d be happy to help you continue building it step by step.

Let me know how you’d like to move forward!

Sherri Hall's profile image
Sherri Hall

you can leverage the concept of workflow reusability. This involves calling the existing "Rename Virtual Machine" workflow as a sub-workflow from your main workflow. You can achieve this by using the "Workflow ID" or a reference to the reusable workflow in your main workflow.

Cuyahoga County Auditor