PowerCLI

 View Only
  • 1.  upgrade vm hardware and tools with one script

    Posted Apr 19, 2015 03:39 PM

    Hi,

    I am looking  for script to upgrading multiple VMs  vmware tools and Hardware version upgrade in one script after running the below script.

    Get-VM | Select Name,@{N='ToolStatus';E={$_.ExtensionData.Guest.ToolsStatus}} |

    export-csv C:\Tools-Report.csv -UseCulture -NoTypeInformation

    Any help on this will be appreciated.

    Thanks

    vm2014



  • 2.  RE: upgrade vm hardware and tools with one script

    Posted Apr 19, 2015 08:50 PM

    You could do something like this

    Import-Csv C:\Tools-Report.csv -UseCulture |

    where{$_.ToolStatus -ne [VMware.Vim.VirtualMachineToolsStatus]::toolsOk} | %{

        $vm = Get-VM $_.Name

        Update-Tools -VM $vm -NoReboot

        $poweredOn = $false

        if($vm.PowerState -ne 'PoweredOff'){

            $poweredOn = $true

            Stop-VM -VM $vm -Confirm:$false

        }

        Set-VM -VM $vm -Version ([VMware.VimAutomation.ViCore.Types.V1.VM.VMVersion]::v10) -Confirm:$false

        if($poweredOn){

            Start-VM -VM $vm -Confirm:$false

        }

    }



  • 3.  RE: upgrade vm hardware and tools with one script

    Posted Apr 20, 2015 02:36 AM

    Thanks LuCD.

    For Hardware version I need to take downtime approval.How about if i  need to upgrade vmware tools  only  without re-boot based on the script i mentioned earlier ?

    Thanks

    vmk2014



  • 4.  RE: upgrade vm hardware and tools with one script

    Posted Apr 20, 2015 04:56 AM

    Then you just leave the Set-VM and following lines (but not the closing curly braces)



  • 5.  RE: upgrade vm hardware and tools with one script

    Posted Apr 20, 2015 02:22 PM

    LucD,

         Just to confirm ?

    Import-Csv C:\Tools-Report.csv -UseCulture |

    where{$_.ToolStatus -ne [VMware.Vim.VirtualMachineToolsStatus]::toolsOk} | %{

        $vm = Get-VM $_.Name

        Update-Tools -VM $vm -NoReboot

        $poweredOn = $false

        if($vm.PowerState -ne 'PoweredOff'){

            $poweredOn = $true

            Stop-VM -VM $vm -Confirm:$false

        }


    thanks


    vmk



  • 6.  RE: upgrade vm hardware and tools with one script
    Best Answer

    Posted Apr 20, 2015 03:39 PM

    In fact this should be enough

    Import-Csv C:\Tools-Report.csv -UseCulture |

    where{$_.ToolStatus -ne [VMware.Vim.VirtualMachineToolsStatus]::toolsOk} | %{

        $vm = Get-VM $_.Name

        Update-Tools -VM $vm -NoReboot

    }