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
}
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
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
That error says that the input file doesn't exist, or can not be found.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Lucd! input file was saved as host.txt.txt. Its working now after correcting it.