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 [ 733 ]
(0 Like)
Rate

#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
$value.tools = 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
$value.tools.toolsUpgradePolicy = "upgradeAtPowerCycle"
$vm.ReconfigVM_Task($value)
    #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.
Join Facebook Group https://www.facebook.com/groups/VMwareInsight/
Like Facebook Page https://www.facebook.com/VMwareInsight/
Connect to twitter https://twitter.com/VMwareInsight
Share this on Social Media

About the Author

Pranay Jha
Pranay Jha
Founder, Contributer VMwareInsight.com
Follow me

facebook linkedin twitter G+ VMTN

My name is Pranay Jha, working in IBM as Technical Solution Architect for Virtualization platform. I have been working in IT for near around 10 years. Passionate to get involved as an Independent blogger for my blog http://vmwareinsight.com. I am VMware vExpert 2016/2017, VCAP5-DCD/DCA, VCP5-DCV, VCA-Cloud, VCE-CIA, MCSE, MCITP, MCSA(Messaging). For any query or suggestion, please connect me at pranay1988jha@gmail.com. Thanks for visiting here.

 
Please SignUp/Login to comment...

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