VMware Cloud Community
pamiller21
Enthusiast
Enthusiast
Jump to solution

HW Version Report

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Something like this

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
12 Replies
BrianDGeorge
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Are these VMs on VMC?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

VMC? Sorry what do you mean?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

vSphere in the Amazon cloud.

For vSphere 6.7 on premises you will need to use v14

From the KB I mentioned earlier.

hwversion.jpg


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

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

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

v15.jpg

You will have to use the API

$vm = Get-VM -Name MyVM

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

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?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
pamiller21
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Something like this

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos