VMware Cloud Community
rgp982
Contributor
Contributor
Jump to solution

Auto Enable UpgradeAtPowerCycle for Windows Servers only.

Script below but it apparently just doesn't do anything. Any help? 

 

# VMware Tools Automatic Upgrade on PowerCycle for Windows Only


Connect-VIserver -server vcenterserver -credential $(get-credential -message "Enter vCenter Credentials")
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
(Get-VM).where{$_.ExtensionData.Config.Tools.ToolsUpgradePolicy -like 'manual' -and $_.GuestOSFullName -match 'Windows'} | ForEach { $_.ExtensionData.ReconfigVM_task($vmConfigSpec) }

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You missed a dot,  $_.GuestOSFullName should be $_.Guest.OSFullName


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

You missed a dot,  $_.GuestOSFullName should be $_.Guest.OSFullName


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

rgp982
Contributor
Contributor
Jump to solution

You're the man!

0 Kudos