Author | Rob Sewell, sqldbawithabeard.com |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Set-DbaAgentJobOutputFile on GitHub.
Want to see the Bill Of Health for this command? Check out Set-DbaAgentJobOutputFile.
Configures the output file path for SQL Server Agent job steps to capture step execution logs.
Modifies the output file location where SQL Server Agent writes job step execution details, error messages, and command output. This centralizes logging for troubleshooting failed jobs, monitoring step execution, and maintaining audit trails without manually editing each job step through SQL Server Management Studio. When no specific step is provided, an interactive selection interface appears for jobs with multiple steps.
Set-DbaAgentJobOutputFile
[-SqlInstance] <DbaInstanceParameter[]>
[-SqlCredential <PSCredential>]
[-Job <Object[]>]
[-Step <Object[]>]
-OutputFile <String>
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Set-DbaAgentJobOutputFile -SqlInstance SERVERNAME -Job 'The Agent Job' -OutPutFile E:\Logs\AgentJobStepOutput.txt
Sets the Job step for The Agent job on SERVERNAME to E:\Logs\AgentJobStepOutput.txt
The target SQL Server instance or instances.
Alias | |
Required | True |
Pipeline | true (ByValue, ByPropertyName) |
Default Value |
Specifies the complete file path where SQL Agent should write job step execution output and error messages.
Use this to centralize job logging in a location accessible for troubleshooting and monitoring. The path must be accessible by the SQL Server service account and should include the filename with
extension.
Alias | |
Required | True |
Pipeline | true (ByValue, ByPropertyName) |
Default Value |
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.
Alias | |
Required | False |
Pipeline | true (ByValue, ByPropertyName) |
Default Value |
Specifies the SQL Server Agent job name whose step output files you want to configure.
Use this to target specific jobs that need centralized logging or troubleshooting. This parameter is not officially mandatory, but you will always be asked to provide a job if you have not.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies which job step(s) within the target job should have their output file configured.
Use this when you only want to set output files for specific steps in multi-step jobs. Step names are unique within each job, making this a reliable way to target individual steps. If omitted and the
job has multiple steps, an interactive GUI will appear for step selection.
Alias | |
Required | False |
Pipeline | true (ByValue, ByPropertyName) |
Default Value |
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 |
Shows what would happen if the command were to run. No actions are actually performed.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts you for confirmation before executing any changing operations within the command.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |