Howa would I cycle through a group of VMs and rename them based on their old name? For example I have 20 VMs named
vm1
vm2, etc.
and I want to rename them to
vm1-old
vm2-old, etc.
doing something like
get-vm vm* | set-vm -name ($_.name+"-old")
This doesn't work quite right however
Thanks
Hello, TheVMinator-
You were pretty close, just needed to add a Foreach-Object loop and operate on each VM returned from Get-VM like so:
Get-VM vm* | %{Set-VM -VM $_ -Name "$($_.Name)-old" -Confirm:$false -WhatIf}
Note that I left the -WhatIf parameter on there so that when you run this, it just shows you what it would do. To actually rename the VMs, just take out the -WhatIf.
Hello, TheVMinator-
You were pretty close, just needed to add a Foreach-Object loop and operate on each VM returned from Get-VM like so:
Get-VM vm* | %{Set-VM -VM $_ -Name "$($_.Name)-old" -Confirm:$false -WhatIf}
Note that I left the -WhatIf parameter on there so that when you run this, it just shows you what it would do. To actually rename the VMs, just take out the -WhatIf.
OK that worked - much appreciated.