Hi,
i am able to list our configured Baselines using PowerGUI with VMware PowerCLI and vCenter UpdateManager PowerCLI...so i think my environment is basically working...
I want to build a script to update my ESX-Hosts from 4.0 to 4.1...The Baseline exists and i can use it in the vCenter-Client...but i want to upgrade the hosts using a script..
Baseline-type is Static, Baseline-Name is "Upgrade ESX4.0 -> ESX4.1, Component is Host-Upgrade...
How does a script have to look like to upgrade a Host name ESXHost12 ?
Thanks in advance
Chakoe
The following sequence should do the trick.
$upgrade = Get-Baseline -Name "Upgrade ESX4.0 -> ESX4.1"
$esx = Get-VMHost ESXHost12
Remediate-Inventory -Baseline $upgrade -Entity $esx -HostDisableMediaDevices:$true -Confirm:$false
The Remediate cmdlet will try to place the host in maintenance mode, if it isn't in that mode already.
If the host is a node in a cluster with DRS set to automatic, the VMs running on the host will be vMotioned to other nodes.
If the node is not in a cluster, you will need to make sure all VMs on that host are stopped before.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
it works, but i am getting the following error and it doesn´t matter if the Host is in Maintenance or not...if is not, the script puts the Host in maintenance mode, but the error still appears...
Remediate-Inventory : 10.04.2011 09:57:25 Remediate-Inventory Operation is not valid due to the current state of the object.
At C:\setzen_ESX-Update_von_Update_Manager.ps1:5 char:21
+ Remediate-Inventory <<<< -Baseline $upgrade -Entity $esx -HostDisableMediaDevices:$true -Confirm:$false
+ CategoryInfo : NotSpecified: (:) [Remediate-Inventory], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VumAutomation.Commands.RemediateInventory
Is the baseline you are using attached to the ESX host ?
You can try to do a
Attache-Baseline -Entity $esx -Baseline $upgrade -Confirm:$aflse
before you do the Remediate-Inventory cmdlet.
After the error you could do the following ?
$Error[0].Exception | Select *
$Error[0].Exception.InnerException | Select *
Perhaps this will show more details about the error.
Which Update Manager snapin version are you using ? 4.0 or 4.1 ?
Get-PowerCLIVersion
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey,
here are the Infos :
########################
PS C:\VMWare PowerShell Scripte> Get-PowerCLIVersion
PowerCLI Version
----------------
VMware vSphere PowerCLI 4.1 U1 build 332441
---------------
Snapin Versions
---------------
VMWare vSphere PowerCLI 4.1 U1 build 332441
VMware vCenter Update Manager PowerCLI 4.1 build 266648
###################
PS C:\VMWare PowerShell Scripte> $Error[0].Exception | Select *
ErrorId : Core_BaseCmdlet_UnknownError
ErrorCategory : NotSpecified
TargetObject :
RecommendedAction : Error occured while executing cmdlet: Remediate-Inventory. Check inner exception for more details.
SessionId :
ConnectionId :
Severity : Error
Message : 10.04.2011 12:28:06 Remediate-Inventory Operation is not valid due to the current state of the object.
Data : {ParameterValues}
InnerException : System.InvalidOperationException: Operation is not valid due to the current state of the object.
at VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl.BeginTaskCompletionPoll(List`1 taskList)
at VMware.VimAutomation.Sdk.Impl.V1.Task.CoreTaskServiceImpl.WaitForTask(IEnumerable`1 taskList, ProgressCallback progressCallback)
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.BaseCmdlet.EndProcessingErrorHandled()
at VMware.VimAutomation.ViCore.Util10Ps.BaseCmdlet.BaseCmdlet.EndProcessingErrorHandled()
TargetSite : Void ThrowTerminatingError(System.Management.Automation.ErrorRecord)
StackTrace : at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
HelpLink :
Source : System.Management.Automation
PS C:\VMWare PowerShell Scripte> $Error[0].Exception.InnerException | Select *
Message : Operation is not valid due to the current state of the object.
Data : {}
InnerException :
TargetSite : Void BeginTaskCompletionPoll(System.Collections.Generic.List`1[VMware.VimAutomation.Sdk.Interop.V1.Task.TaskInterop])
StackTrace : at VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl.BeginTaskCompletionPoll(List`1 taskList)
at VMware.VimAutomation.Sdk.Impl.V1.Task.CoreTaskServiceImpl.WaitForTask(IEnumerable`1 taskList, ProgressCallback progressCallback)
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.BaseCmdlet.EndProcessingErrorHandled()
at VMware.VimAutomation.ViCore.Util10Ps.BaseCmdlet.BaseCmdlet.EndProcessingErrorHandled()
HelpLink :
Source : VMware.VimAutomation.ViCore.Impl
The error object doesn't seem to provide any clues as to why the Remediate-Inventory failed ![]()
The baseline is attached to the ESX server I assume ?
Does
Get-Baseline -Entity $esx
show the upgrade baseline ?
Anything in the vpxd log that gives more information about the failure ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Attaching the Baseline to the esx-hosts does not make any difference ![]()
I remember seeing a thread where an update of ESX 4.0 didn't work with the 4.1 VUM snapin. But I can't find the link back right now.
Can you try uninstalling the VUM 4.1 snapin and installing the VUM 4.0 U1 snapin ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Because we are using multiple baselines for the esx-hosts
1) Upgrade ESX4 -> ESX4.1
2) Patch for ESX 4.1.0 Build 320092
i don´t think the problem will be solved when using the old snapin...we are updating from 4.1.0 to an later 4.1.0 build... ![]()
So I´m going to ignore the error , are there ways tu suppred them in this script ?
Then, i tried to modify the script to select hosts from a cluster which are in maintenance mode and only install the baselines to these
hosts....the errors are appearing but nothing happens to the hosts???
Here´s the actual script:
###########################
$upgrade = Get-Baseline -Name "ESX4.1 Patch Release 201011001 "
$esx = Get-VMHost d100spwesxc23*.d100.intern | Where-Object {$_.ConnectionState -eq "Maintenance"} |Sort-Object $_.Name
Remediate-Inventory -Baseline $upgrade -Entity $esx -HostDisableMediaDevices:$true -Confirm:$false
Get-VMHost $esx | ForEach-Object {
Remediate-Inventory -Baseline $upgrade -Entity $esx -HostDisableMediaDevices:$true -Confirm:$false
}
###########################
It seems that i´m not fit enough in selfmade-scripting ![]()
In the beginning of the thread you said you were upgrading from 4.0 to 4.1.
I would strongly suggest to try the upgrade with the VUM snapin 4.0U1.
You can't ignore the error because the hosts are not upgraded !
To upgrade all the hosts in a cluster you could do
$upgrade = Get-Baseline -Name "ESX4.1 Patch Release 201011001 "
$esx = Get-Cluster -Name MyCluster | Get-VMHost | Where-Object {$_.State -eq "Maintenance"}
Remediate-Inventory -Baseline $upgrade -Entity $esx -HostDisableMediaDevices:$true -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
that´s life:
My Boss came and said: You have to install the Update from ESX 4.0 to ESX4.1 and then i also
have to install the Patch for ESX 4.1.... ![]()
So, a lot more to do...
The Script writes the error we were talking about, but the script nevertheless works...it only writes the error and the hosts are being
updated....strange ![]()
So i think i should ignore the error, because the hosts are updated now ( I have a script to check the ESX Version including the Build-number, it is
ESX 4.1.0 320092 )
The following error appears when i try to upgrade multiple hosts simultanously:
Remediate-Inventory : Cannot convert 'System.Object[]' to the type 'VMware.VimAutomation.ViCore.Types.V1.Inventory.InventoryItem' required by parameter 'Entity'. Specified method is not supported.
At C:\VMWare PowerShell Scripte\setzen_ESX-Update_von_Update_Manager.ps1:10 char:48
+ Remediate-Inventory -Baseline $upgrade -Entity <<<< $esx -HostDisableMediaDevices:$true -Confirm:$false
+ CategoryInfo : InvalidArgument: (:) [Remediate-Inventory], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,VMware.VumAutomation.Commands.RemediateInventory
Does the Parameter "-Entity" support a list of Hosts, or do i have to use a function like forEach?
The -Entity parameter doesn't support a list of hosts. But it accepts values from the pipeline. So you could do it like this:
$upgrade = Get-Baseline -Name "ESX4.1 Patch Release 201011001 " Get-VMHost d100spwesxc23*.d100.intern | ` Where-Object {$_.ConnectionState -eq "Maintenance"} | ` Sort-Object -Property Name | ` Remediate-Inventory -Baseline $upgrade -HostDisableMediaDevices:$true -Confirm:$false
My mistake, the Entity parameter apparently doesn't support an array of objects.
So you could do
$upgrade = Get-Baseline -Name "ESX4.1 Patch Release 201011001 "
Get-Cluster -Name MyCluster | Get-VMHost | Where-Object {$_.State -eq "Maintenance"} | %{
Remediate-Inventory -Entity $_ -Baseline $upgrade -HostDisableMediaDevices:$true -Confirm:$false}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
both ways are working ![]()
So, i have a working script with errormessages which are to be ignored
Remediate-Inventory : 11.04.2011 14:13:00 Remediate-Inventory Operation is not valid due to the current state of the object.
At C:\VMWare PowerShell Scripte\setzen_ESX-Update_von_Update_Manager_v2.ps1:12 char:27
+ Remediate-Inventory <<<< -Entity $_ -Baseline $upgrade -HostDisableMediaDevices:$true -Confirm:$false
+ CategoryInfo : NotSpecified: (:) [Remediate-Inventory], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VumAutomation.Commands.RemediateInventory
So...if there isn´t a real reason for this error ( because the hosts are being updated corretly )...isn´t there a way to suppress
the errors?
But.....Hey...thanks for your support...I´m looking for a good course to learn some PowerCLI / PowerShell Scripting ( basics),
because i would like to be able to build my own scripts ![]()
You can try adding the prrameter -ErrorAction SlientlyCOntinue.
But this will also make all other potential errors invisible. I wouldn't advise you to do that.
I find the free ebook from Tobias a good source to learn PowerShell.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
