VMware Cloud Community
vmk2014
Expert
Expert
Jump to solution

Can we pull VMware tools version and VM's HW version for specific lists of VMs ?

Hello Everyone,

Can we pull the VMware tools version and VM's HW version for the specific lists of VMs into CSV ? E.g. C:\Temp\vmliste.txt

I want to ensure that we are upgrading the VM's having older version of tools & HW

Thanks

vmk

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The only cause for this error I can think of, is that you have an empty (blank) line in that .txt file.

Let's skip any blank line.

$vmNames = Get-Content -Path C:\Temp\vmliste.txt | where{$_}

Write-Host "Count: $($vmNames.Count)"

Get-VM -Name $vmNames |

Select Name,

    @{N='VMVersion';E={$_.HardwareVersion}},

    @{N='ToolsStatus';E={$_.Guest.EXtensionData.ToolsVersionStatus}} |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

View solution in original post

Reply
0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

You mean like this?

Get-VM -Name (Get-Content -Path C:\Temp\vmliste.txt) |

Select Name,

    @{N='VMVersion';E={$_.HardwareVersion}},

    @{N='ToolsStatus';E={$_.Guest.EXtensionData.ToolsVersionStatus}} |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

Reply
0 Kudos
vmk2014
Expert
Expert
Jump to solution

LucD,

It throws an error..

PS C:\temp> .\VMware-tools-HW-version.ps1

Get-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not

null or empty, and then try the command again.

At C:\temp\VMware-tools-HW-version.ps1:4 char:14

+ Get-VM -Name (Get-Content -Path C:\Temp\vmliste.txt) |

+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [Get-VM], ParameterBindingValidationException

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Are you sure your .txt file contains some VMnames?

Does this return anything?

Get-Content -Path C:\Temp\vmliste.txt


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

Reply
0 Kudos
vmk2014
Expert
Expert
Jump to solution

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

And what does this one say?

$vmNames = Get-Content -Path C:\Temp\vmliste.txt

Write-Host "Count: $($vmNames.Count)"

Get-VM -Name $vmNames |

Select Name,

    @{N='VMVersion';E={$_.HardwareVersion}},

    @{N='ToolsStatus';E={$_.Guest.EXtensionData.ToolsVersionStatus}} |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

Reply
0 Kudos
vmk2014
Expert
Expert
Jump to solution

Here you go

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The only cause for this error I can think of, is that you have an empty (blank) line in that .txt file.

Let's skip any blank line.

$vmNames = Get-Content -Path C:\Temp\vmliste.txt | where{$_}

Write-Host "Count: $($vmNames.Count)"

Get-VM -Name $vmNames |

Select Name,

    @{N='VMVersion';E={$_.HardwareVersion}},

    @{N='ToolsStatus';E={$_.Guest.EXtensionData.ToolsVersionStatus}} |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

Reply
0 Kudos
vmk2014
Expert
Expert
Jump to solution

LucD,

Need your help here. Can we add Hostname ( VM running on which host ) and ESXi version also becuase we are tragetting to upgrade VM's running on ESXi 6.5. We have mix of 6.5 & 5.5 hosts

thanks

vmk

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

$vmNames = Get-Content -Path C:\Temp\vmliste.txt | where {$_}

Write-Host "Count: $($vmNames.Count)"

Get-VM -Name $vmNames |

  Select Name,

@{N = 'VMVersion'; E = {$_.HardwareVersion}},

@{N = 'ToolsStatus'; E = {$_.Guest.EXtensionData.ToolsVersionStatus}},

@{N = 'VMHost'; E = {$_.VMHost.Name}},

@{N = 'ESXiVersion'; E = {$_.VMHost.Version}} |

   Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

Reply
0 Kudos
vmk2014
Expert
Expert
Jump to solution

Thank you.

Reply
0 Kudos