Hello,
Want to run the below shown PS script. The only issue that I have now is writing to the output file with a comma delimiter. I should also have the column header. Can you please help with this?
Currently, when I open up the output file using Excel, there is no column separation. So, comma delimiter will help.
=================
##Save the below powershell script in folder "E:\PowerShellScripts\SQLServersBackupStatusFromMSDB.ps1"$QueryPath= "E:\PowerShellScripts\BackupStatusQuery1.sql"
$OutputFile = "E:\PowerShellScripts\BackupStatusQuery1_Output.csv"
$ExecuteQuery= Get-Content -path $QueryPath | out-string
#"Results -- > `r`n`r`n" > $OutputFile
FOREACH($server in GC "E:\PowerShellScripts\SQLServerList.txt")
{
$server
#"---------------------------------------------------------------------------------------------------------">> $OutputFile
#$server >> $OutputFile
#"---------------------------------------------------------------------------------------------------------">> $OutputFile
invoke-sqlcmd -ServerInstance $server -query $ExecuteQuery -querytimeout 65534 | ft -autosize | out-string -width 4096 >> $OutputFile
}
==============
Victor
Victor