Try this:
$dt = new-object "System.Data.DataTable" # create the datatable once
get-content "D:\DBA\PSScripts\SQLServerList.txt" |
ForEach-Object{
$cn = new-object System.Data.SqlClient.SqlConnection "server=$_;database=master;Integrated Security=sspi"
$cn.Open()
$sql = $cn.CreateCommand()
$sql.CommandText = "SELECT
@@SERVERNAME as ServerName,
SERVERPROPERTY('ProductVersion') AS BuildNumber,
SERVERPROPERTY('Edition') AS Edition,
SERVERPROPERTY('ProductLevel') AS ProductLevel,
SERVERPROPERTY('ProductUpdateLevel') AS UpdateLevel,
SERVERPROPERTY('ProductUpdateReference') AS UpdateReference,
SERVERPROPERTY('ProductMajorVersion') AS Major,
SERVERPROPERTY('ProductMinorVersion') AS Minor,
SERVERPROPERTY('ProductBuild') AS Build"
$rdr = $sql.ExecuteReader()
$dt.Load($rdr) # this should merge the data with existing data
$cn.Close()
}
$dt | Export-CSV D:\DBA\PSScripts\output.txt -NoTypeInfo -Force
Keep in mind that a CSV cannot preserve the data type of the exported data. Everything in a CSV is text. If you want to preserve the data types you'll have to write the data to XML.