Obsoleet
Platinum Member
I'm trying to output certain data to a CSV file, but it's slapping all the information from all fields into a single spreadsheet cell.
You can see I'm pulling certain variables, then putting them into a temporary file. Then putting that into another file using Out-File, this is the only way I could get it to append after my script ran through each server (rather than overwriting the last server's information).
But after you open up Excel it looks like this example from cell A1, when I want Excel to respect the imported data as comma separated-
Parent,"Version","Name","LastBackupDate","LastLogBackupDate","Size","SpaceAvailable"
I haven't found anyway to make Out-File import the information into the final file in a way that is correct.. any ideas? Thank you
You can see I'm pulling certain variables, then putting them into a temporary file. Then putting that into another file using Out-File, this is the only way I could get it to append after my script ran through each server (rather than overwriting the last server's information).
Code:
$dbs = $s.Databases
$dbs | select Parent, Version, Name, LastBackupDate, LastLogBackupDate, Size, SpaceAvailable | Export-Csv "C:\Documents and Settings\Desktop\sqlservers\SERVER\TempDatabase.csv" -notype
[System.IO.File]::ReadAllText("C:\Documents and Settings\Desktop\sqlservers\SERVER\TempDatabase.csv") | Out-File "C:\Documents and Settings\Desktop\sqlservers\SERVER\BACKUP_GEN_Information.csv" -Append
But after you open up Excel it looks like this example from cell A1, when I want Excel to respect the imported data as comma separated-
Parent,"Version","Name","LastBackupDate","LastLogBackupDate","Size","SpaceAvailable"
I haven't found anyway to make Out-File import the information into the final file in a way that is correct.. any ideas? Thank you