Hi,
I cannot seem to find the correct way to update the virtual hardware from 4 to 7 using powerCLI. I have searched and read every post out here and other places on this topic, and all of the methods listed do not seem to work for various reasons, most of them being invalid cmdlets or something of the sort.
I have 4.1CLI, and just need to update VH from v4 to v7. I have found a few ways to script the Virtual tools to upgrade (some work, and some don't, buggy), so I can work through this part. But lets assume I have a vm, or severa,l currently on v4, tools are up to date on a 4.1 ESX host, vm(s) is powered off, what are the corect commands?
Any help or insight would be appreicated.
Thanks!
First, let's bring the script down to basics. Arne's script contains indeed a lot of reporting and other nice features.
This is in fact all you need
Get-VM | where {$_.Extensiondata.Config.Version -eq "vmx-04" -and $_.PowerState -eq "PoweredOff"} | %{ $_.Extensiondata.UpgradeVM("vmx-07") }
Save the lines above in a file with a filetype of .ps1.
These lines will get all your guests and only select the ones that are still on hardware version 4 and that are powered off.
For those guest, the hardware version will be set to v7.
Start the PowerCLI prompt.
Make sure the PowerShell execution policy is set. You can do
Get-ExecutionPolicy
to verify and the following to set it.
Set-ExecutionPolicy RemoteSigned
Note that you have to do this only once. The setting will be retained until you change it again.
Before running the script make sure you are connected to the vCenter. Do
Connect-VIServer -Server MyvCenter
Then start the script in the .ps1 file from the promt
.\MyScript.ps1
Provided you are position in the directory where the .ps1 file is stored.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Have a look at Arne's blog post called PowerCLI: Upgrading vHardware to vSphere Part 2: VM’s.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have looked at this already and a couple things are confusing. First, let me throw out there that I am new to PowerCLI, and most scripting of this nature in general, so please forgive the stupid questions to follow...
1) what do I need to change in this script to fit my environment? It looks like just my vcenter name and folder that contains the vm's I want to run this against, is this correct?
2) how do I run the script? Is it saved a a .bat or executible file and simply run this way, or is there a preferred method?
I appreciate the help. So far I have concured some of the one line basic functionality, and I'm looking forward to learning more.
Thanks!
First, let's bring the script down to basics. Arne's script contains indeed a lot of reporting and other nice features.
This is in fact all you need
Get-VM | where {$_.Extensiondata.Config.Version -eq "vmx-04" -and $_.PowerState -eq "PoweredOff"} | %{ $_.Extensiondata.UpgradeVM("vmx-07") }
Save the lines above in a file with a filetype of .ps1.
These lines will get all your guests and only select the ones that are still on hardware version 4 and that are powered off.
For those guest, the hardware version will be set to v7.
Start the PowerCLI prompt.
Make sure the PowerShell execution policy is set. You can do
Get-ExecutionPolicy
to verify and the following to set it.
Set-ExecutionPolicy RemoteSigned
Note that you have to do this only once. The setting will be retained until you change it again.
Before running the script make sure you are connected to the vCenter. Do
Connect-VIServer -Server MyvCenter
Then start the script in the .ps1 file from the promt
.\MyScript.ps1
Provided you are position in the directory where the .ps1 file is stored.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ok, awesome!
One more question;
What is the best way to isolate this to one vm, or a .txt file containing some vm's versus quering all that ffit the version and powerstate?
Thanks!
For one specific VM you can do
Get-VM -Name MyVM | %{ $_.Extensiondata.UpgradeVM("vmx-07") }
If you have a .txt file with the name of a VM on each line, you can do
Get-Content "C:\vmnames.txt" | %{
Get-VM -Name $_ | %{$_.Extensiondata.UpgradeVM("vmx-07")}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Lucd,
You are the man! I really appreicate the help man, this is awesome. I now have enough useful info to form a couple different ways of doing this to fit the environment.
Thanks again!