Hi Team,
We understand using set-vm in powercli we could rename a vm display name and then perform@ storage vmotion, as a newbie in scripting is there an option to perform the same task in bulk,we have around 100 vms that needs vm display name changed. My thoughts are having two entries in a single file (.csv) with old name and new name, how do I ensure for each vm name in the column, its corresponding new name is set . I am thinking foreach loop for it, however unable to get the syntax/ code right, please advise., thanks in advance for your support. LucD
The rename of the DisplayName can indeed be done with the Set-VM cmdlet.
But how do you plan to do the svMotion?
Is there a specific destination to which the VM can be moved?
The rename is a simple loop
# oldname,newname
# vm1,newvm1
# vm2,newvm2
Import-Csv -Path .\rename.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
Get-VM -Name $row.oldname |
Set-VM -Name $row.newname -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The rename of the DisplayName can indeed be done with the Set-VM cmdlet.
But how do you plan to do the svMotion?
Is there a specific destination to which the VM can be moved?
The rename is a simple loop
# oldname,newname
# vm1,newvm1
# vm2,newvm2
Import-Csv -Path .\rename.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
Get-VM -Name $row.oldname |
Set-VM -Name $row.newname -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You are awesome as always LucD
I am using move-vm in bulk to move these vms to a new datastore and then they remain in that location.
Thanks again for your support.