Please enable Javascript for better experience...
Powershell Script to Enable VM Tool Option "Check and Upgrade Tools during power cycling"
By Pranay Jha | May 4, 2016 | In Tips | Total Views [ 4105 ]
(0 Like)

#list name of servers on which changes required in file
$n = Get-Content "D:\pranay\VMName.txt"
foreach ($b in $n){
    #Command will extact details of VM
$vm = Get-VM -Name $b | % {Get-View $_.ID}
$value = New-Object VMware.Vim.VirtualMachineConfigSpec
$ = New-Object VMware.Vim.ToolsConfigInfo
    #This is where you mention which policy need to enter ,here we only need to enable checkbox to uprade vmware tools at power cycle. Same has been selected
$ = "upgradeAtPowerCycle"
    #Below command will export the policy details of all VMs(updated/yet to be updated) in respective VC in csv format.
get-view -ViewType virtualmachine | select name,@{N='ToolsUpgradePolicy';E={$_.Config.Tools.ToolsUpgradePolicy } } | Export-Csv "D:\ToolsOutput.csv" -UseCulture -NoTypeInformation

    #or if we only need to export of tasks executed for number of VM then remove last line and add below instead of get-view:
$vm.ReconfigVM_Task($value)| Export-Csv "D:\ToolsOutput.csv" -UseCulture -NoTypeInformation

Thanks for visiting here. Share this article if you found it useful.
Like Facebook Page
Connect to twitter
Subscribe my Channel
Connect over Linkedin
Share this on Social Media

About the Author

Pranay Jha
Pranay Jha
Founder, Contributer

Public profile: user/profile/99900000

Follow me

facebook linkedin twitter G+ VMTN youtube

Thank you for visiting my profile. I am Pranay Jha, bring along a total of 11+ years of extensive experience with me in Information Technology sector for organizations from small business to large enterprises, wherein my current assignment I am associated with IBM as a Technical Solution Architect for Virtualization platform. I am vExpert x 3 (16/17/18), VCIX-DCV, VCAP5/6-DCD, VCAP5-DCA, VCP7-CMA, VCP5/6-DCV, VCA-DCV, VCA-Cloud, VSP, VCE-CIA, MCITP, MCSE, MCSA(Messaging). I am also an Independent blogger and founder of and I can be reached via email at or Direct Message via Contact Us form.

Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Facebook Likes