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
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
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
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
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
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
Here you go
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
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
Try like this
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
Thank you.