< Back

Get-DbaAgentJobOutputFile

Mon Jan 13, 2020 10:18 am

NAME Get-DbaAgentJobOutputFile



SYNOPSIS

Returns the Output File for each step of one or many agent job with the Job Names provided dynamically if

required for one or more SQL Instances





SYNTAX

Get-DbaAgentJobOutputFile [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>

[[-SqlCredential] <Pscredential>] [-Job <System.Object[]>] [-ExcludeJob <System.Object[]>] [-EnableException

<Switch>] [<CommonParameters>]





DESCRIPTION

This function returns for one or more SQL Instances the output file value for each step of one or many agent job

with the Job Names



provided dynamically. It will not return anything if there is no Output File





PARAMETERS

-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ExcludeJob [<System.Object[]>]

The job(s) to exclude - this list is auto-populated from the server



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Job [<System.Object[]>]

The job(s) to process - this list is auto-populated from the server. If unspecified, all jobs will be

processed.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).



Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -

Integrated are all supported.



For MFA support, please use Connect-DbaInstance. be it Windows or SQL Server. Windows users are determined by

the existence of a backslash, so if you are intending to use an alternative Windows connection instead of a

SQL login, ensure it contains a backslash.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the

function to be executed against multiple SQL Server instances.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Agent, Job

Author: Rob Sewell (https://sqldbawithabeard.com) | Simone Bizzotto (@niphold)



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-DbaAgentJobOutputFile -SqlInstance SERVERNAME -Job 'The Agent Job'



This will return the configured paths to the output files for each of the job step of the The Agent Job Job

on the SERVERNAME instance

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-DbaAgentJobOutputFile -SqlInstance SERVERNAME



This will return the configured paths to the output files for each of the job step of all the Agent Jobs

on the SERVERNAME instance

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-DbaAgentJobOutputFile -SqlInstance SERVERNAME,SERVERNAME2 -Job 'The Agent Job'



This will return the configured paths to the output files for each of the job step of the The Agent Job Job

on the SERVERNAME instance and SERVERNAME2

-------------------------- EXAMPLE 4 --------------------------



PS C:\\>$Servers = 'SERVER','SERVER\\INSTANCE1'



Get-DbaAgentJobOutputFile -SqlInstance $Servers -Job 'The Agent Job' -OpenFile



This will return the configured paths to the output files for each of the job step of the The Agent Job Job

on the SERVER instance and the SERVER\\INSTANCE1 and open the files if they are available

-------------------------- EXAMPLE 5 --------------------------



PS C:\\>Get-DbaAgentJobOutputFile -SqlInstance SERVERNAME | Out-GridView



This will return the configured paths to the output files for each of the job step of all the Agent Jobs

on the SERVERNAME instance and Pipe them to Out-GridView

-------------------------- EXAMPLE 6 --------------------------



PS C:\\>(Get-DbaAgentJobOutputFile -SqlInstance SERVERNAME | Out-GridView -PassThru).FileName | Invoke-Item



This will return the configured paths to the output files for each of the job step of all the Agent Jobs

on the SERVERNAME instance and Pipe them to Out-GridView and enable you to choose the output

file and open it

-------------------------- EXAMPLE 7 --------------------------



PS C:\\>Get-DbaAgentJobOutputFile -SqlInstance SERVERNAME -Verbose



This will return the configured paths to the output files for each of the job step of all the Agent Jobs

on the SERVERNAME instance and also show the job steps without an output file



RELATED LINKS