Skip to content

Getting the output of the checks in different file formats

Rob Sewell edited this page Sep 6, 2018 · 1 revision

Getting the output of the checks in different file formats

If you want to get the output of the checks into different file outputs you can find examples below

# set a config
Set-DbcConfig -name app.sqlinstance -value localhost

# run a check and output an xml file
Invoke-DbcCheck -Check AutoClose -OutputFile C:\temp\dbachecks.xml -OutputFormat NUnitXml

# open the file (in VS Code)
Open-EditorFile C:\temp\dbachecks.xml

# run a check and save results to a variable
$TestResults = Invoke-DbcCheck -Check AutoClose -PassThru

# summary
$TestResults

# the first detailed test result
$TestResults.TestResult[0]

# Convert to text file
$TestResults.TestResult | Out-File c:\temp\dbachecks.txt

Open-EditorFile C:\temp\dbachecks.txt

#convert to csv
$TestResults.TestResult | ConvertTo-Csv -NoTypeInformation |Out-File c:\temp\dbachecks.csv

Open-EditorFile C:\temp\dbachecks.csv

# convert to html (its rubbish but..)
$TestResults.TestResult | ConvertTo-Html |Out-File C:\temp\dbachecks.html

. C:\temp\dbachecks.html

# convert to json
$TestResults.TestResult | ConvertTo-Json |Out-File C:\temp\dbachecks.json

Open-EditorFile C:\temp\dbachecks.json

# install the importexcel module
Install-Module importexcel

$TestResults.TestResult | Export-Excel -Path c:\temp\dbachecks.xlsx 

. c:\temp\dbachecks.xlsx 

#Want what you see on the screen in a file?

Invoke-DbcCheck -Check AutoClose *> c:\temp\dbachecks_log.txt

Open-EditorFile C:\temp\dbachecks_log.txt