Hi Lucd ,
Kindly help me out with powercli script for Mass update of VMtools manually from Shared folder.
Scenario:- Store the VMtools.exe (VMware-tools-11.2.6-17901274-x86_64.exe) from shared folder and Update the same via script in multiple VM's.
Below is the script I'm trying..no go with it.
#Variables
$computername = Get-Content c:\temp\servers.txt
$sourcefile = "c:\temp\VMware-tools-11.2.6-17901274-x86_64.exe"
#This section will install the software
foreach ($computer in $computername)
{
$destinationFolder = "\\$computer\C$\Temp"
#It will copy $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
if (!(Test-Path -path $destinationFolder))
{
New-Item $destinationFolder -Type Directory
}
Copy-Item -Path $sourcefile -Destination $destinationFolder
Invoke-Command -ComputerName $computer -ScriptBlock {Start-Process 'c:\temp\VMware-tools-11.2.6-17901274-x86_64.exe'}
}
Kindly assist me ...Thanks in advance.
Regards,
Kumar
No error messages?
Can you enable logging on the EXE?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
I'm able to copy the .EXE to remote VM on C:\TEMP, but it's not executing the exe automatically.
no error, But stuck her from past 20 min
or any other way I can execute VM tools instead of doing it manually on Multiple Server's.
Regards,
Kumar
That sounds as if the script is waiting with a prompt (you don't see) to allow admin privileges.
Is UAC enabled?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for your reply ..
I have to verify with Windows team whether UAC is enabled or disabled. If it's enabled , than i don't know whether i can disable it.
When i checked in the system I'm running it's "enabled to notify"
There is any way i can bypass this notify one & run automatically other than disabling (UAC) manually in all VM's
Regards,
Kumar
It's not advised to bypass UAC using PowerShell. You would need to change registry values on the remote machine in order to achieve this.
Is it possible to have a service account with admin privileges' created for scripts to run under?
I have a code snippet that will set your VM to upgrade Tools on next OS reboot. You could easily modify this and use it how you want in your environment. I'm assuming your VMs reboot at least once a month for some sort of patching:
$ToolsAutoSettingsVMs = Get-Cluster | Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName", "Config.Tools.ToolsUpgradePolicy") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}}, @{N="Running OS";E={$_.Guest.GuestFullName}}, @{N='ToolsUpgradePolicy';E={$_.Config.Tools.ToolsUpgradePolicy }}
ForEach ($VM in ($ToolsAutoSettingVMs)){
$VMConfig = Get-View -VIObject $VM.Name
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
$VMConfig.ReconfigVM($vmConfigSpec)
}
Hi Norris,
Thanks a lot...I can try this one...But if i want to do one particular cluster...?? how can i do that..!
Regards,
Kumar
You can put your cluster name after the Get-Cluster command in the first line as follows:
$ToolsAutoSettingsVMs = Get-Cluster "CLUSTERNAMEHERE" | Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName", "Config.Tools.ToolsUpgradePolicy") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}}, @{N="Running OS";E={$_.Guest.GuestFullName}}, @{N='ToolsUpgradePolicy';E={$_.Config.Tools.ToolsUpgradePolicy }} |
Hi Norris ...Thanks a lot ....you made my day..!!
I will try the below script if any issues ..i will keep you posted.
Thanks a lot.
Cheers,
Kumar.
Glad to hear it! You're very welcome. Look forward to hearing back on how it goes 🙂 -- Cheers!
Hi Norris,
One more help. Instead of cluster name...can I change to one Single ESXI HOST there ..??
$ToolsAutoSettingsVMs = Get-Host "ESXIHOST NAME HERE" | Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName", "Config.Tools.ToolsUpgradePolicy") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}}, @{N="Running OS";E={$_.Guest.GuestFullName}}, @{N='ToolsUpgradePolicy';E={$_.Config.Tools.ToolsUpgradePolicy }}
Whether this works..??
Regards,
Kumar.
Try this:
$ToolsAutoSettingsVMs = Get-VMHost "ESXIHOST NAME HERE" | Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName", "Config.Tools.ToolsUpgradePolicy") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}}, @{N="Running OS";E={$_.Guest.GuestFullName}}, @{N='ToolsUpgradePolicy';E={$_.Config.Tools.ToolsUpgradePolicy }} |
Hi Norris,
Thanks a lot ...!
I will check and updated you !
Cheers,
Kumar