< Back

Set-DbaAgentServer

Mon Jan 13, 2020 5:29 pm

NAME Set-DbaAgentServer



SYNOPSIS

Set-DbaAgentServer updates properties of a SQL Agent Server.





SYNTAX

Set-DbaAgentServer [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential]

<Pscredential>] [[-InputObject] <Microsoft.SqlServer.Management.Smo.Agent.JobServer[]>] [[-AgentLogLevel]

<System.Object>] [[-AgentMailType] <System.Object>] [[-AgentShutdownWaitTime] <Int>] [[-DatabaseMailProfile]

<String>] [[-ErrorLogFile] <String>] [[-IdleCpuDuration] <Int>] [[-IdleCpuPercentage] <Int>] [[-CpuPolling]

<String>] [[-LocalHostAlias] <String>] [[-LoginTimeout] <Int>] [[-MaximumHistoryRows] <Int>]

[[-MaximumJobHistoryRows] <Int>] [[-NetSendRecipient] <String>] [[-ReplaceAlertTokens] <String>]

[[-SaveInSentFolder] <String>] [[-SqlAgentAutoStart] <String>] [[-SqlAgentMailProfile] <String>]

[[-SqlAgentRestart] <String>] [[-SqlServerRestart] <String>] [[-WriteOemErrorLog] <String>] [-EnableException

<Switch>] [<CommonParameters>]





DESCRIPTION

Set-DbaAgentServer updates properties in the SQL Server Server with parameters supplied.





PARAMETERS

-AgentLogLevel [<System.Object>]

Specifies the agent log level.

Allowed values 1, "Errors", 2, "Warnings", 3, "Errors, Warnings", 4, "Informational", 5, "Errors,

Informational", 6, "Warnings, Informational", 7, "All"

The text value can either be lowercase, uppercase or something in between as long as the text is correct.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-AgentMailType [<System.Object>]

Specifies the agent mail type.

Allowed values 0, "SqlAgentMail", 1, "DatabaseMail"

The text value can either be lowercase, uppercase or something in between as long as the text is correct.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-AgentShutdownWaitTime [<Int>]

The Agent Shutdown Wait Time value of the server agent.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CpuPolling [<String>]

Enable or Disable the Polling.

Allowed values Enabled, Disabled



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DatabaseMailProfile [<String>]

The Database Mail Profile to be used. Must exists on database mail profiles.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-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



-ErrorLogFile [<String>]

Error log file location



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-IdleCpuDuration [<Int>]

Idle CPU Duration value to be used



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-IdleCpuPercentage [<Int>]

Idle CPU Percentage value to be used



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InputObject [<Microsoft.SqlServer.Management.Smo.Agent.JobServer[]>]

Enables piping agent server objects



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-LocalHostAlias [<String>]

The value for Local Host Alias configuration



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-LoginTimeout [<Int>]

The value for Login Timeout configuration



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-MaximumHistoryRows [<Int>]

Indicates the Maximum job history log size (in rows). If you want to turn it off use the value -1



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-MaximumJobHistoryRows [<Int>]

Indicates the Maximum job history rows per job. If you want to turn it off use the value 0



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-NetSendRecipient [<String>]

The Net send recipient value



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ReplaceAlertTokens [<String>]

Enable or Disable the Token replacement property.

Allowed values Enabled, Disabled



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SaveInSentFolder [<String>]

Enable or Disable the copy of the sent messages is save in the Sent Items folder.

Allowed values Enabled, Disabled



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlAgentAutoStart [<String>]

Enable or Disable the SQL Agent Auto Start.

Allowed values Enabled, Disabled



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlAgentMailProfile [<String>]

The SQL Server Agent Mail Profile to be used. Must exists on database mail profiles.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlAgentRestart [<String>]

Enable or Disable the SQL Agent Restart.

Allowed values Enabled, Disabled



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.



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. You must have sysadmin access and server version must be SQL

Server version 2000 or greater.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlServerRestart [<String>]

Enable or Disable the SQL Server Restart.

Allowed values Enabled, Disabled



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-WriteOemErrorLog [<String>]

Enable or Disable the Write OEM Error Log.

Allowed values Enabled, Disabled



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, Server

Author: Cl????????udio Silva (@claudioessilva), https://claudioessilva.com



Website: https://dbatools.io

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

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



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



PS C:\\>Set-DbaAgentServer -SqlInstance sql1 -MaximumHistoryRows 10000 -MaximumJobHistoryRows 100



Changes the job history retention to 10000 rows with an maximum of 100 rows per job.

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



PS C:\\>Set-DbaAgentServer -SqlInstance sql1 -CpuPolling Enabled



Enable the CPU Polling configurations.

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



PS C:\\>Set-DbaAgentServer -SqlInstance sql1, sql2, sql3 -AgentLogLevel 'Errors, Warnings'



Set the agent log level to Errors and Warnings on multiple servers.

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



PS C:\\>Set-DbaAgentServer -SqlInstance sql1 -CpuPolling Disabled



Disable the CPU Polling configurations.



RELATED LINKS

https://dbatools.io/Set-DbaAgentServer