Hello,
We are upgrading VMs from Windows 7 to Windows 10, and need to change Guest OS and version after the upgrade on multiple VMs.
Looking for a script to automate it.
Thank you in advance!
Something like this?
$spec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec
$spec.GuestId = [VMware.Vim.VirtualMachineGuestOsIdentifier]::windows9_64Guest
$vm.ExtensionData.ReconfigVM($spec)
$vm.ExtensionData.UpgradeVM('vmx-15')
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello Luc,
Thank you, How can it run against a list of VMs?
You could do something like this.
This assumes that the .TXT file contains 1 VMname per line.
$spec.GuestId = [VMware.Vim.VirtualMachineGuestOsIdentifier]::windows9_64Guest
Get-VM -Name (Get-Content -Path .\vmnames.txt) |
ForEach-Object -Process {
$_.ExtensionData.ReconfigVM($spec)
$_.ExtensionData.UpgradeVM('vmx-15')
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello Luc,
What does this line do?
.ExtensionData.UpgradeVM('vmx-15')
It calls the UpgradeVM API method on the VM.
The string parameter specifies which HW version to upgrade to.
$vm.ExtensionData.UpgradeVM('vmx-15')
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference