I have powershell that reads from a database and successfully outputs. Problem is, when I insert commas, the program ignores it so when I open .csv file, all the data is in one column instead of five columns. How to fix this?
$count=0
do{
try{
$rdr = $cmd.ExecuteReader()
while ($rdr.read()){
$sql_output += ,@($rdr.GetValue(0), ",", $rdr.GetValue(1), ",", $rdr.GetValue(2), ",", $rdr.GetValue(3), ",", $rdr.GetValue(4))
$count=$count + 1
}
$transactionComplete = $true
}
catch{
$transactionComplete = $false
}
}until ($transactionComplete)
$conn.Close()
foreach ($k in $sql_output){
Add-Content D:\Script\Network_Threat_Protection.csv "$k"
}