b1naryagent's Posts

Actually, with further testing we discovered that using the parameter "always" rather than "onSoftPowerOff" does cause the hardware to be upgraded on a reboot cycle and does not require a power d... See more...
Actually, with further testing we discovered that using the parameter "always" rather than "onSoftPowerOff" does cause the hardware to be upgraded on a reboot cycle and does not require a power down cycle. Here's the updated code: $vm = Get-VM -Name MyVM $spec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec $spec.ScheduledHardwareUpgradeInfo = New-Object -TypeName VMware.Vim.ScheduledHardwareUpgradeInfo $spec.ScheduledHardwareUpgradeInfo.UpgradePolicy = "always" $spec.ScheduledHardwareUpgradeInfo.VersionKey = "vmx-10" $vm.ExtensionData.ReconfigVM_Task($spec) Also, if you want to upgrade tools and hardware in the same reboot cycle here is some code that will do that but will only upgrade hardware on VM's that complete the tools upgrade successfully. I borrowed from LucD's task processing code to monitor the background async tasks: $vms = get-content ./vm_upgrades.txt function Upgd-Hdwr($vm){   $spec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec   $spec.ScheduledHardwareUpgradeInfo = New-Object -TypeName VMware.Vim.ScheduledHardwareUpgradeInfo   $spec.ScheduledHardwareUpgradeInfo.UpgradePolicy = "always"   $spec.ScheduledHardwareUpgradeInfo.VersionKey = "vmx-10"   $vm.ExtensionData.ReconfigVM_Task($spec) } $taskTab = @{} foreach($vm in $vms){   $taskTab[(Update-Tools -vm (Get-VM $vm) -NoReboot -RunAsync).Id] = $vm } $runningTasks = $taskTab.Count while($runningTasks -gt 0){   Get-Task | %{   if($taskTab.ContainsKey($_.Id) -and $_.State -eq "Success"){   Write-Host "VMtools on $($taskTab[$_.Id]) was upgraded successfully. Scheduling virtual hardware upgrade..."   add-content ./tools_success.txt -value $($taskTab[$_.Id])   Upgd-Hdwr (Get-VM $taskTab[$_.Id])   $taskTab.Remove($_.Id)   $runningTasks--   }   elseif($taskTab.ContainsKey($_.Id) -and $_.State -eq "Error"){   write-Warning "There was a problem with $($taskTab[$_.Id]), please check the VMtools upgrade manually."   add-content ./tools_fail.txt -value $($taskTab[$_.Id])   $taskTab.Remove($_.Id)   $runningTasks--   }   }   Start-Sleep -Seconds 15 }
This method does not work. I tested the code and after two restarts the VM's would not upgrade. The VM must be powered down for the upgrade to occur. The documentation clearly states, onSoftPo... See more...
This method does not work. I tested the code and after two restarts the VM's would not upgrade. The VM must be powered down for the upgrade to occur. The documentation clearly states, onSoftPowerOff - Run scheduled upgrades only on normal guest OS shutdown.
I had also tried: Get-Template "Win2003 ENT R2 SP2 x64 10.7.124.x" | Move-Template -Destination esxhost110.blah.pvt That command passes the template object via the pipeline to the input of ... See more...
I had also tried: Get-Template "Win2003 ENT R2 SP2 x64 10.7.124.x" | Move-Template -Destination esxhost110.blah.pvt That command passes the template object via the pipeline to the input of move-template but I received the same error. Also, I was informed by my teammates that you can't move templates across ESX hosts and that they must be converted to VM's first. With that information I was able to move the templates. My concern here is that the documentation for move-template specifies that the Destination parameter can be any VIContainer which includes "folder, host, cluster, or resource pool". Nowhere does it mention any restriction on the destination in regards to what type of VIContainer can be specified. This is woefully unacceptable.
Vcenter 5.5 U1 PowerCli 5.5 R2 PowerShell 3.0 PowerCLI C:\> Move-Template -Template "Win2003 ENT R2 SP2 x64 10.7.124.x" -Destination esxhost110.blah.pvt  -WhatIf Move-Template : Unable to... See more...
Vcenter 5.5 U1 PowerCli 5.5 R2 PowerShell 3.0 PowerCLI C:\> Move-Template -Template "Win2003 ENT R2 SP2 x64 10.7.124.x" -Destination esxhost110.blah.pvt  -WhatIf Move-Template : Unable to cast object of type 'VMware.VimAutomation.ViCore.Util10.Surrogate.DefaultValue.StringWrapperFolder' to type 'VMware.VimAutomation.ViCore.Interop.V1.VIObjectCoreInterop'. At line:1 char:14 + Move-Template <<<<  -Destination esxhost110.blah.pvt -Template "Win2003 ENT R2 SP2 x64 10.7.124.x" -WhatIf     + CategoryInfo          : NotSpecified: (:) [Move-Template], InvalidCastException     + FullyQualifiedErrorId : System.InvalidCastException,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveTemplate
Fix verified. Thanks much to you and the team for the quick turnaround.
Verified on 2 systems: PowerCLI C:\_data\Scripts\Powershell Scripts> get-patch get-patch : 3/12/2014 1:24:19 PM Get-Patch        Method 'get_RelatedSrmService' in type 'VMware.VumAutomation.C... See more...
Verified on 2 systems: PowerCLI C:\_data\Scripts\Powershell Scripts> get-patch get-patch : 3/12/2014 1:24:19 PM Get-Patch        Method 'get_RelatedSrmService' in type 'VMware.VumAutomation.Clien t40.VumClient' from assembly 'VMware.VumAutomation.Client40, Version=5.5.0.17854, Culture=neutral, PublicKeyToken=null' does not have an implementation. At line:1 char:10 + get-patch <<<<     + CategoryInfo          : NotSpecified: (:) [Get-Patch], VimException     + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VumAutomation.Commands.GetPatch get-patch : 3/12/2014 1:24:19 PM Get-Patch        Method 'get_RelatedSrmService' in type 'VMware.VumAutomation.Clien t40.VumClient' from assembly 'VMware.VumAutomation.Client40, Version=5.5.0.17854, Culture=neutral, PublicKeyToken=null' does not have an implementation. At line:1 char:10 + get-patch <<<<     + CategoryInfo          : NotSpecified: (:) [Get-Patch], VimException     + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VumAutomation.Commands.GetPatch
Not really for compatibility but to launch in Powershell 2 mode so VUM & View snapins won't crash. Open the properties of your PowerCli shortcut and replace the command with this. C:\Window... See more...
Not really for compatibility but to launch in Powershell 2 mode so VUM & View snapins won't crash. Open the properties of your PowerCli shortcut and replace the command with this. C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 2 -psc "C:\PROGRA~2\VMware\Infrastructure\VSPHER~1\vim.psc1" -noe -c ". \"C:\PROGRA~2\VMware\Infrastructure\VSPHER~1\Scripts\Initialize-PowerCLIEnvironment.ps1\"" If you just add "-version 2" to the current command you'll get errors. These errors are caused because the length of the command is over the 259 character limit. I used the 8.3 notation to get around the limitation. You might want to verify the paths on your system.