I have a function that simply pulls the SPF, DKIM and DMARC records to a file and the console.
Name : Domain.com
SpfRecord : v=spf1 ip4:?.1?.??.153 include: <Etc?>
SpfAdvisory : An SPF-record
DmarcRecord : v=DMARC1;
DmarcAdvisory : Domain has a valid DMARC record.
DkimRecord : <Etc>
DkimSelector : <Etc>
DkimAdvisory : <Etc>
When I $InvokeReturnValues | Export-Csv 'C:\Reports\SPFetc.csv' -NoTypeInformation
The information exports across the csv left to right in columns.
How can I change that so the information exports like above?
CodePudding user response:
Since you don't actually want a CSV file, don't use Export-Csv
.
Out-File
or Set-Content
will do just fine:
$InvokeReturnValues |Format-List |Out-File
Depending on the input data type, Format-List
may not be explicitly necessary - in this case where you have an array of custom objects with more than 4 properties, PowerShell will automatically format it using the List view anyway.
If you're considering use of the data for further automation - an automatic diff of two versions of the data for example - you might want to stick with CSV.
You can always re-create the list view in your console by simply importing the data again:
$oldData = Import-Csv path\to\SPFetc.csv
$oldData |Format-List