VMware Cloud Community
SatishB20111014
Contributor
Contributor
Jump to solution

Multiple Hosts Versions

Hi All,

I am beginner in powercli scripts. I require a powercli script to get the version of multiple hosts from a input file and as well as output in a text file.

I created the below script for that but getting error while running it. Please assist on it.

Thanks in advance!!

$HostList = Get-Content D:\host.txt

foreach ($hostName in $HostList) {
$version = Get-VMhost $hostName @{$_.Config.Product.FullName}

$version | Out-File c:\temp\test.txt - append

}

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VMHost -Name (Get-Content D:\host.txt) |

Select Name,

    @{N='Product';E={$_.ExtensionData.Config.Product.FullName}} |

Out-File c:\temp\test.txt -Append


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VMHost -Name (Get-Content D:\host.txt) |

Select Name,

    @{N='Product';E={$_.ExtensionData.Config.Product.FullName}} |

Out-File c:\temp\test.txt -Append


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

0 Kudos
SatishB20111014
Contributor
Contributor
Jump to solution

Thanks for your reply.

I getting the attached error when it is executed. Please advice.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That error says that the input file doesn't exist, or can not be found.


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

0 Kudos
SatishB20111014
Contributor
Contributor
Jump to solution

Thanks Lucd! input file was saved as host.txt.txt. Its working now after correcting it.

0 Kudos