dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


This command copies SQL Agent proxy accounts from one SQL Server to another. By default, all proxy accounts are copied.

The -ProxyAccounts parameter is autopopulated for command-line completion and can be used to copy only specific proxy accounts.

If the proxy account already exists on the destination, it will be skipped unless -Force is specified. Force drops and recreates the object. Dependencies are not currently copied over.


To copy all proxy accounts from sqlserver2014a to sqlcluster, using integrated (Windows) authentication. If proxy accounts with the same name exist on sqlcluster, they will be skipped.

Copy-SqlProxyAccount -Source sqlserver2014a -Destination sqlcluster

To copy only two proxy accounts, dboperator1 and murrringoperator, from sqlserver2014a to sqlcluster, using SQL authentication for sqlserver2014a and integrated (Windows) authentication for sqlcluster. If a proxy account with the same name exists on sqlcluster, it will be dropped and recreated because -Force was used.

Copy-SqlProxyAccount -Source sqlserver2014a -Destination sqlcluster -ProxyAccounts dboperator1, murrringoperator -SourceSqlCredential sqladmin -Force

To see what would happen if the command were executed. No actions are actually performed.

Copy-SqlProxyAccount -Source sqlserver2014a -Destination sqlcluster -WhatIf


From PowerShell, execute Get-Help Copy-SqlProxyAccount -Detailed for more information on this function.

Source Code

Want to see the source code? View Copy-SqlProxyAccount.ps1 on GitHub

Related commands