< Back
New-DbaAgentProxy
Post
NAME New-DbaAgentProxy
SYNOPSIS
Adds one or more proxies to SQL Server Agent
SYNTAX
New-DbaAgentProxy [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-SqlCredential]
<Pscredential>] [-Name] <System.String[]> [-ProxyCredential] <System.String[]> [[-SubSystem] <System.String[]>]
[[-Description] <String>] [[-Login] <System.String[]>] [[-ServerRole] <System.String[]>] [[-MsdbRole]
<System.String[]>] [-Disabled <Switch>] [-Force <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Adds one or more proxies to SQL Server Agent
PARAMETERS
-Description [<String>]
A description of the proxy
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Disabled [<Switch>]
Create the proxy as disabled
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
-Force [<Switch>]
Drop and recreate the proxy if it already exists
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Login [<System.String[]>]
The SQL Server login or logins (known as proxy principals) to assign to the proxy
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MsdbRole [<System.String[]>]
The msdb role or roles (known as proxy principals) to assign to the proxy
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Name [<System.String[]>]
The name of the proxy or proxies you want to create
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ProxyCredential [<System.String[]>]
The associated SQL Server Credential. The credential must be created prior to creating the Proxy.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ServerRole [<System.String[]>]
The SQL Server role or roles (known as proxy principals) to assign to the proxy
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 higher.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SubSystem [<System.String[]>]
The associated subsystem or subsystems. Defaults to CmdExec.
Valid options include:
ActiveScripting
AnalysisCommand
AnalysisQuery
CmdExec
Distribution
LogReader
Merge
PowerShell
QueueReader
Snapshot
Ssis
TransactSql
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, Proxy
Author: Chrissy LeMaire (@cl), netnerds.net
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>New-DbaAgentProxy -SqlInstance sql2016 -Name STIG -ProxyCredential 'PowerShell Proxy'
Creates an Agent Proxy on sql2016 with the name STIG with the 'PowerShell Proxy' credential.
The proxy is automatically added to the CmdExec subsystem.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>New-DbaAgentProxy -SqlInstance localhost\\sql2016 -Name STIG -ProxyCredential 'PowerShell Proxy'
-Description "Used for auditing purposes" -Login ad\\sqlstig -SubSystem CmdExec, PowerShell -ServerRole
securtyadmin -MsdbRole ServerGroupAdministratorRole
Creates an Agent Proxy on sql2016 with the name STIG with the 'PowerShell Proxy' credential and the following
principals:
Login: ad\\sqlstig
ServerRole: securtyadmin
MsdbRole: ServerGroupAdministratorRole
By default, only sysadmins have access to create job steps with proxies. This will allow 3 additional principals
access:
The proxy is then added to the CmdExec and PowerShell subsystems
RELATED LINKS
https://dbatools.io/New-DbaAgentProxy
SYNOPSIS
Adds one or more proxies to SQL Server Agent
SYNTAX
New-DbaAgentProxy [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-SqlCredential]
<Pscredential>] [-Name] <System.String[]> [-ProxyCredential] <System.String[]> [[-SubSystem] <System.String[]>]
[[-Description] <String>] [[-Login] <System.String[]>] [[-ServerRole] <System.String[]>] [[-MsdbRole]
<System.String[]>] [-Disabled <Switch>] [-Force <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Adds one or more proxies to SQL Server Agent
PARAMETERS
-Description [<String>]
A description of the proxy
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Disabled [<Switch>]
Create the proxy as disabled
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
-Force [<Switch>]
Drop and recreate the proxy if it already exists
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Login [<System.String[]>]
The SQL Server login or logins (known as proxy principals) to assign to the proxy
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MsdbRole [<System.String[]>]
The msdb role or roles (known as proxy principals) to assign to the proxy
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Name [<System.String[]>]
The name of the proxy or proxies you want to create
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ProxyCredential [<System.String[]>]
The associated SQL Server Credential. The credential must be created prior to creating the Proxy.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ServerRole [<System.String[]>]
The SQL Server role or roles (known as proxy principals) to assign to the proxy
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 higher.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SubSystem [<System.String[]>]
The associated subsystem or subsystems. Defaults to CmdExec.
Valid options include:
ActiveScripting
AnalysisCommand
AnalysisQuery
CmdExec
Distribution
LogReader
Merge
PowerShell
QueueReader
Snapshot
Ssis
TransactSql
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, Proxy
Author: Chrissy LeMaire (@cl), netnerds.net
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>New-DbaAgentProxy -SqlInstance sql2016 -Name STIG -ProxyCredential 'PowerShell Proxy'
Creates an Agent Proxy on sql2016 with the name STIG with the 'PowerShell Proxy' credential.
The proxy is automatically added to the CmdExec subsystem.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>New-DbaAgentProxy -SqlInstance localhost\\sql2016 -Name STIG -ProxyCredential 'PowerShell Proxy'
-Description "Used for auditing purposes" -Login ad\\sqlstig -SubSystem CmdExec, PowerShell -ServerRole
securtyadmin -MsdbRole ServerGroupAdministratorRole
Creates an Agent Proxy on sql2016 with the name STIG with the 'PowerShell Proxy' credential and the following
principals:
Login: ad\\sqlstig
ServerRole: securtyadmin
MsdbRole: ServerGroupAdministratorRole
By default, only sysadmins have access to create job steps with proxies. This will allow 3 additional principals
access:
The proxy is then added to the CmdExec and PowerShell subsystems
RELATED LINKS
https://dbatools.io/New-DbaAgentProxy