commands

^

Export-DbaDiagnosticQuery

Author Andre Kamman (@AndreKamman), clouddba.io
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Export-DbaDiagnosticQuery on GitHub.
Want to see the Bill Of Health for this command? Check out Export-DbaDiagnosticQuery.

Synopsis

Export-DbaDiagnosticQuery can convert output generated by Invoke-DbaDiagnosticQuery to CSV or Excel

Description

The default output format of Invoke-DbaDiagnosticQuery is a custom object. It can also output to CSV and Excel.
However, CSV output can generate a lot of files and Excel output depends on the ImportExcel module by Doug Finke (https://github.com/dfinke/ImportExcel)
Export-DbaDiagnosticQuery can be used to convert from the default export type to the other available export types.

Syntax

Export-DbaDiagnosticQuery
    [-InputObject] <Object[]>
    [[-ConvertTo] <String>]
    [[-Path] <FileInfo>]
    [[-Suffix] <String>]
    [-NoPlanExport]
    [-NoQueryExport]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Invoke-DbaDiagnosticQuery -SqlInstance sql2016 | Export-DbaDiagnosticQuery -Path c:\temp

Converts output from Invoke-DbaDiagnosticQuery to multiple CSV files

Example: 2
PS C:\> $output = Invoke-DbaDiagnosticQuery -SqlInstance sql2016
PS C:\> Export-DbaDiagnosticQuery -InputObject $output -ConvertTo Excel

Converts output from Invoke-DbaDiagnosticQuery to Excel worksheet(s) in the Documents folder

Required Parameters

-InputObject

Specifies the objects to convert

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-ConvertTo

Specifies the output type. Valid choices are Excel and CSV. CSV is the default.

Alias
Required False
Pipeline false
Default Value Csv
Accepted Values Excel,Csv
-Path

Specifies the path to the output files.

Alias
Required False
Pipeline false
Default Value (Get-DbatoolsConfigValue -FullName 'Path.DbatoolsExport')
-Suffix

Suffix for the filename. It's datetime by default.

Alias
Required False
Pipeline false
Default Value "$(Get-Date -format 'yyyyMMddHHmmssms')"
-NoPlanExport

Use this switch to suppress exporting of .sqlplan files

Alias
Required False
Pipeline false
Default Value False
-NoQueryExport

Use this switch to suppress exporting of .sql files

Alias
Required False
Pipeline false
Default Value False
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False