VMware Cloud Community
Mallik7
Enthusiast
Enthusiast
Jump to solution

in need of a PowerCLI script

I'm in need of a PowerCLI script to get the ESXi host OS version with build number for the required servers (input should be taken from a text file) and

output to be captured in a .csv file, kindly help...

TIA

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-VMHost -Name (Get-Content -Path .\esxnames.txt) |

Select Name,Version,Build |

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


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-VMHost -Name (Get-Content -Path .\esxnames.txt) |

Select Name,Version,Build |

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


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

Gidrakos
Hot Shot
Hot Shot
Jump to solution

Please and thank you go a long way, but here ya go:

$csvFile = [Path to csv file]

$hosts = Import-CSV -path $csvFile

$output = @()

forEach ($line in $hosts) {

     $hostname = $line.hostname

     $outPut += (Get-VMHost $hostname | Select-Object name,version, build)

}

$output | Export-CSV [Path to export file] -force

Reply
0 Kudos