hi Luc D,
could you share your thoughts on following plan.
we are planning to upgrade esxi hosts to 6.5 from 5.5.
iam planning to automate this to have very less manual intervention.
foolowing is the logical plan .
a:compare each esxi host with standard version i.e 6.5.
b.if it fails then proceed to put host in maintenance mode.
c:once host is in maintenance mode install 6.5 using iso stored in one of the data store.
what power cli syntax used here.???
d:once host is upgraded to 6.5 proceed to next host.
appreciate your help
There could be something wrong in the file that analyses modules, see Module Analysis Cache
You can try to reset that file.
Stop all your PowerShell/PowerCLI sessions, then delete the ModuleAnalysisCache file.
Start a PowerShell session, and do an Import-Module -Name VMware.VumAutomation.
Restart the PowerShell session, and then check if Get-Baseline can be found, and the module auto-loaded.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Why not use the Update Manager module in PowerCLI.
You can upload an ESXi image (ISO) to the Update Manager, and then create a Baseline with that ESXi image (this has to be done via the Web Client, no cmdlet afaik)
From here you script the process with cmdlets from the Update Manager module.
Attach the baseline to the target ESXi nodes (Attach-Baseline) and then do a Scan-Inventory.
You then take the VMHosts that need the upgrade one-by-one.
Place them in maintenance mode, and then apply the update with Update-Entity.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
After the upgrade you might want to scan for critical and non-critical patches (these baselines are pre-configured), and eventually apply the missing patches.
You can limit the patches to be applied by date and name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for your suggestion iam going to check this .
I think we can do this with power cli 6.5 as we are in progress of doing upgrade to power cli 10.1.
Yes, that should work.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
But none of the commands(attach-baseline,scan-inventory) which you mentioned in your last post are available.
is there a separate module for update manager or is it contained in one of the modules which i shared through screenshot.
Refering to image which i shared in previous post.
They are in the module VMware.VumAutomation, and yes, that module is in your screenshot.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
Good Morning,
could you check the following script and suggest what needs to be modified .Iam assuming there is no vmotion restriction while putting the host in maintenece mode.
also if you could suggest how to put progress task
and what is _runasync parameter means.
$vcenter=read-host "vcenter name"
$user=read-host "user name"
$password = read-host "password for vcenter"
$cluster=read-host "cluster to be upgradeted"
$std_version=Read-Host "what version you want to upgrade to"
$baseline=esxi6.5 upgrade
connect-viserver -server $vcenter -User $user -Password $password
$hosts_cluster=get-vmhost -location $cluster
$count=$hosts_cluster.count
$count
foreach ($esxi in $hosts_cluster)
{
if ($esxi.version -ne $std_version)
{
write-host $esxi.name "needs to be upgraded to " $std_version
write-host "putting host" $esxi.name "in mainteneace mode"
Set-VMHost -VMHost $esxi -State "Maintenance" -RunAsync
}
#how to put progress task
Attach-Baseline -Entity $esxi -Baseline $baseline
Update-Entity -Baseline $baseline -Entity $esxi -RunAsync
#how to put progreess task.
}
The Baseline parameter on the Attach-Baseline cmdlets needs to hold an object returned by the Get-Baseline cmdlet, not a string.
You can do
$baseline = Get-Baseline -Name 'esxi6.5 upgrade'
Attach-Baseline -Entity $esxi -Baseline $baseline
The RunAsync parameter makes the cmdlet run in the background, and return a Task object
You script will continue, while the task continues running.
See also about_RunAsync
A progress bar can be realised withe Write-Progress cmdlet.
But you need to calculate/find what percentage of the task is completed.
See for exampleRe: Capturing the progress of a task and outputting to another application
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks.i m checking this.
while checking i found get-baseline and attach-baseline are running directly from powercli console not from powershell(though i can execute other powercli commands from powershell)
i think we need to reload only the update manger module or suggest what else can be done .
Are you sure you have a module for Update Manager, and not a PSSnapin?
Do a
Get-Module -Name VMware* -ListAvailable
Get-PSSnapin -Name VMware* -Registered
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
well just to reconfirm in powercli 6.5 we concluded earlier that modules replaced snapin is that not correct.??
also from above screenshot i see VMware.VumAutomation (the maodule that provides get-baseline and attach-baseline is available ) .
Indeed, just wanted to make sure you were having the module.
So what exactly do you mean then by "...while checking i found get-baseline and attach-baseline are running directly from powercli console not from powershell(though i can execute other powercli commands from powershell)"?
Can you show us?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
so what i meant is when i run get-baseline from powershell i got following (though all modules of powercli are loaded to powershell)
but if i run the same command get-baseline from powercli i get output .
if you check the vum automation module(in previous screen shot) its version is 6.0 can this be a problem .
There could be something wrong in the file that analyses modules, see Module Analysis Cache
You can try to reset that file.
Stop all your PowerShell/PowerCLI sessions, then delete the ModuleAnalysisCache file.
Start a PowerShell session, and do an Import-Module -Name VMware.VumAutomation.
Restart the PowerShell session, and then check if Get-Baseline can be found, and the module auto-loaded.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
that has worked now i can see those commands in power shell.
However iam still working on completing the script of upgrading esxi to 6.5 as per your suggestion we can add progress bar as following . copied the following code from one of your posts for creation of vm .however can you check if it works for putting host in maintenance mode.or anything else that needs to be added .
appreciate your help on this.
The Set-VMHost has to run as a background task, add the RunAsync switch to the cmdlet
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference