Guys
anyone knows how to create a powershell in order to get the esxi host list on each vcenter and add some words to the output file like you can see the format below???
### DoNotRemoveOrModifyThisLine
serverName techspecName
a23veiesx01 techspec_generic_Remediation.csv
a23veiesx02 techspec_generic_Remediation.cs
thx inn advance!!!!
Just add it to the array after the 1st line.
$report += '### DoNotRemoveOrModifyThisLine'
$report += 'serverName techspecName'
Get-VMHost | ForEach-Object -Process {
$report += "{0} {1}" -f $_.Name,'Some text'
}
$report | Out-File -FilePath .\report.txt
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not quite sure what you are asking for. What is techspecName? and what are you expecting in the .csv files?
JPsider no matter what is the text close the the esxi hostname....i need to get that format....similar what what i write below
##sometthing
serverName techspecName
esxihostname something.csv
i cat get that info using
Get-VMHost | Select name > tests.csv
and i get this
Name
----
twigaesxi01.tw.ibm.com
twigaesxi02.tw.ibm.com
sgveiesx11
sgveiesx09
sgveiesx10
and i need this on the output file
### DoNotRemoveOrModifyThisLine
serverName techspecName
a23veiesx01 techspec_generic_Remediation.csv
a23veiesx02 techspec_generic_Remediation.csv
Great thx for your help
Try something like this.
But note that this is not a valid CSV file.
$report += '### DoNotRemoveOrModifyThisLine'
Get-VMHost | ForEach-Object -Process {
$report += "{0} {1}" -f $_.Name,'Some text'
}
$report | Out-File -FilePath .\report.txt
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Lucd
this works awesome...you da men..just one more thing...how can i add a new line below this one "### DoNotRemoveOrModifyThisLine" as you can see below in bold.....
great thx in advance!!!!!!
### DoNotRemoveOrModifyThisLine
serverName techspecName
a23veiesx01 techspec_generic_HC.csv
a23veiesx02 techspec_generic_HC.csv
Just add it to the array after the 1st line.
$report += '### DoNotRemoveOrModifyThisLine'
$report += 'serverName techspecName'
Get-VMHost | ForEach-Object -Process {
$report += "{0} {1}" -f $_.Name,'Some text'
}
$report | Out-File -FilePath .\report.txt
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great Thx Sir..you teach me a lot...as usual
Lucd
How can i convert this output file in a csv file with TAB as delimiter???
Great Thx
Export-Csv -Delimiter `t -Path 'yourfile.csv' This will put double quotes on everything. If you want to replace those, you will need to add an extra line of Powershell
Try like this
$report += "###`tDoNotRemoveOrModifyThisLine"
$report += "serverName`ttechspecName"
Get-VMHost | ForEach-Object -Process {
$report += "{0}`t{1}" -f $_.Name,'Some text'
}
$report | Out-File -FilePath .\report.csv
To read this as a CSV you will have to specify the delimiter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference