PowerCLI

 View Only
Expand all | Collapse all

HW Version Report

  • 1.  HW Version Report

    Posted Sep 17, 2019 06:07 PM

    I have been running this report for sometime to check the hardware version and I just adjusted it to detect version 15 and now I get reports of UNKNOWN.  Is there a new setting I need to be looking for?

    #############################

    #    Connect to vCenter     #

    #############################

    Import-Module -Name VMware.PowerCLI

    Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false -InvalidCertificateAction ignore -confirm:$false

    $vc = 'FQDN Name'

    $Cred = Import-Clixml C:\util\Scripts\creds\autoitjob2.xml

    Connect-VIServer $VC -Credential $Cred

    #############################

    #         Variables         #

    #############################

    $date=Get-Date -format "yyyy-MMM-d"

    $datetime=Get-Date

    $filelocation="C:\util\Scripts\Temp\HV-$date.htm"

    $report = Get-VM | where { $_.Version -notmatch "v15" } | Select Name, Version

    #############################

    # Add Text to the HTML file #

    #############################

    $report | ConvertTo-Html –title "VMware Hardware Version" –body "<H1>VMware Hardware Version</H1>" -head "<link rel='stylesheet' href='style.css' type='text/css' />" | Out-File $filelocation

    ConvertTo-Html –title "VMware Hardware Version" –body "<H4>Date and time</H4>",$datetime -head "<link rel='stylesheet' href='style.css' type='text/css' />" | Out-File -Append $filelocation

    ConvertTo-Html –title "VMware Hardware Version" –body "<H4>VM Count</H4>",$report.Count -head "<link rel='stylesheet' href='style.css' type='text/css' />" | Out-File -Append $filelocation

    ######################

    # FTP HTML output #

    #####################

    #we specify the directory where all files that we want to upload 

    $Dir="$filelocation"

    #ftp server

    $ftp = "ftp://IP/internal-backups/datacenter/vcenter/misc-reports/HW/"

    $user = "internal-ftp-backup"

    $pass = "PW" 

    $webclient = New-Object System.Net.WebClient

    $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass) 

    #list every sql server trace file

    foreach($item in (dir $Dir "*.bak")){

        "Uploading $item..."

        $uri = New-Object System.Uri($ftp+$item.Name)

        $webclient.UploadFile($uri, $item.FullName)

    }

    ##############################

    # Disconnect session from VC #

    ##############################

    disconnect-viserver -confirm:$false



  • 2.  RE: HW Version Report

    Posted Sep 17, 2019 06:52 PM

    I just ran it with no issue, with the following caveat: WARNING: The 'Version' property of VirtualMachine type is deprecated. Use the 'HardwareVersion' property instead.

    Get-VM | where { $_.config.Version -notmatch "v15" } | Select Name, Version works as well.



  • 3.  RE: HW Version Report

    Posted Sep 18, 2019 04:03 AM

    It is probably due to the PowerCLI version you are using.
    Older versions don't know the 'v15' value.



  • 4.  RE: HW Version Report

    Posted Sep 19, 2019 02:32 PM

    I updated my powercli to 11.3 with same results

    PS C:\> Get-PowerCLIVersion

    PowerCLI Version

    ----------------

       VMware PowerCLI 11.3.0 build 13990089

    ---------------

    Component Versions

    ---------------

       VMware Cis Core PowerCLI Component PowerCLI Component 11.3 build 13964830

       VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 11.3 build 13964826

       VMware VimAutomation Srm PowerCLI Component PowerCLI Component 11.2 build 12483605

       VMware VimAutomation License PowerCLI Component PowerCLI Component 11.3 build 13990093

       VMware VimAutomation Vds Commands PowerCLI Component PowerCLI Component 11.2 build 12483615

       VMware Vmc PowerCLI Component PowerCLI Component 11.3 build 13964814

       VMware Nsxt PowerCLI Component PowerCLI Component 11.3 build 13964817

       VMware VimAutomation vROps PowerCLI Component PowerCLI Component 10.0 build 7893921

       VMware HorizonView PowerCLI Component 7.1.0 build 14170454

       VMware VimAutomation Cloud PowerCLI Component PowerCLI Component 11.0 build 10379994

       VMWare ImageBuilder PowerCLI Component 6.7 build 11233116

       VMWare AutoDeploy PowerCLI Component 6.7 build 11233116

       VMware VimAutomation Storage PowerCLI Component PowerCLI Component 11.4 build 14293163

       VMware vSphere Update Manager PowerCLI 6.5 build 7862888

       VMware VimAutomation Security PowerCLI Component PowerCLI Component 11.0 build 10380515

       VMware Hcx PowerCLI Component PowerCLI Component 11.4 build 14413360



  • 5.  RE: HW Version Report

    Posted Sep 19, 2019 03:14 PM

    The v15 HW version is used for VMs on VMC, see KB1003746

    Are these VMs on VMC?



  • 6.  RE: HW Version Report

    Posted Sep 19, 2019 09:00 PM

    VMC? Sorry what do you mean?



  • 7.  RE: HW Version Report

    Posted Sep 20, 2019 06:39 PM

    vSphere in the Amazon cloud.

    For vSphere 6.7 on premises you will need to use v14

    From the KB I mentioned earlier.



  • 8.  RE: HW Version Report

    Posted Sep 20, 2019 07:50 PM

    But I am running 6.7u2 which is v15 and it shows this in my vCenter:



  • 9.  RE: HW Version Report

    Posted Sep 20, 2019 08:22 PM

    My bad, it looks as if the latest PowerCLI (11.4.0), doesn't know the v15 value yet.

    You will have to use the API

    $vm = Get-VM -Name MyVM

    $vm.ExtensionData.UpgradeVM('vmx-15')



  • 10.  RE: HW Version Report

    Posted Oct 30, 2019 06:10 PM

    I just updated to the newest version, 11.5 and it still hasn't corrected the issue? Is this still not added to the newest build?



  • 11.  RE: HW Version Report

    Posted Oct 30, 2019 06:29 PM

    I'm afraid not, it supports up to v14, but not v15.

    You can filter on the property in the ExtensionData

    $vm | select Version

    $vm.ExtensionData.Config.Version



  • 12.  RE: HW Version Report

    Posted Oct 31, 2019 01:53 PM

    Not sure how to fit that into my report script :/

    #############################

    #         Variables         #

    #############################

    $date=Get-Date -format "yyyy-MMM-d"

    $datetime=Get-Date

    $filelocation="C:\util\Scripts\Temp\HV-$date.htm"

    $report = Get-VM | where { $_.Version -notmatch "v15" } | Select Name, Version

    #############################

    # Add Text to the HTML file #

    #############################

    $report | ConvertTo-Html –title "VMware Hardware Version" –body "<H1>VMware Hardware Version</H1>" -head "<link rel='stylesheet' href='style.css' type='text/css' />" | Out-File $filelocation

    ConvertTo-Html –title "VMware Hardware Version" –body "<H4>Date and time</H4>",$datetime -head "<link rel='stylesheet' href='style.css' type='text/css' />" | Out-File -Append $filelocation

    ConvertTo-Html –title "VMware Hardware Version" –body "<H4>VM Count</H4>",$report.Count -head "<link rel='stylesheet' href='style.css' type='text/css' />" | Out-File -Append $filelocation



  • 13.  RE: HW Version Report
    Best Answer

    Posted Oct 31, 2019 02:12 PM

    Something like this

    $report = Get-VM | where { $_.ExtensionData.Config.Version -notmatch "vmx-15" } | Select Name, Version