Execution Flow
AD account validation is performed via
Get-sqmADAccountStatus before any SMO operations. If the account is disabled, locked, or has an expired password or account, the function throws immediately without connecting to SQL Server. Use -Force to replace an existing proxy with the same name.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | Target SQL Server instance. Default: $env:COMPUTERNAME. |
| -ProxyName | String | Required | Name for the new Agent proxy account. |
| -ProxyDescription | String | Optional | Description stored on the proxy object. |
| -WindowsCredential | PSCredential | Optional | Windows account for the proxy. If omitted, Get-Credential is invoked interactively. |
| -Subsystem | String[] | Optional | One or more of: CmdExec, Ssis, PowerShell, All. Default: CmdExec. |
| -Force | Switch | Optional | Drop and recreate the proxy if a proxy with the same name already exists. |
| -EnableException | Switch | Optional | Throw exceptions immediately on error. |
| -WhatIf | Switch | Optional | Preview actions without creating any objects. |
| -Confirm | Switch | Optional | Prompt before creating objects. |
Return Value
Returns a PSCustomObject with: SqlInstance, ProxyName, CredentialName, WindowsAccount, Subsystems, Status (Created / Replaced / WhatIfSkipped), Message.
Examples
Example 1 — Create proxy with interactive credential prompt
New-sqmAgentProxy -SqlInstance "SQL01" -ProxyName "DBA_Proxy"
Example 2 — All subsystems with stored credential
$cred = Get-Credential "DOMAIN\svc_sqlagent"
New-sqmAgentProxy -SqlInstance "SQL01" -ProxyName "SSIS_Proxy" `
-WindowsCredential $cred -Subsystem "All" `
-ProxyDescription "SSIS and PowerShell proxy for DBA jobs"
Example 3 — Replace existing proxy with -Force
New-sqmAgentProxy -SqlInstance "SQL01" -ProxyName "DBA_Proxy" `
-WindowsCredential $cred -Subsystem "CmdExec", "PowerShell" -Force