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


Copy-AuditSpecification

Migrates audit specifications from one SQL Server to another. By default, all audit specifications are copied. The -AuditSpecifications parameter is autopopulated for command-line completion and can be used to copy only specific audit specifications.

If the audit specification already exists on the destination, it will be skipped unless -Force is specified. Force drops and recreates the audit specification.

Examples

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

To copy only two audit specifications, LoginAuditSpecs and TableModAuditSpecs, from sqlserver2014a to sqlcluster, using SQL audit specifications for sqlserver2014a and Windows audit specifications for sqlcluster. If an audit specification with the same name exists on sqlcluster, it will be dropped and recreated because -Force was used.

To see what would happen if the command were executed without actually performing an actions are actually performed.

Get-Help

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

Source Code

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

Related commands