Copy-DbaServerAuditSpecification

Copy-DbaServerAuditSpecification migrates server audit specifications from one SQL Server to another.

By default, all audits are copied. The -AuditSpecification parameter is auto-populated for command-line completion and can be used to copy only specific audits.
If the audit specification already exists on the destination, it will be skipped unless -Force is used.

Screenshots

dbatools - Copy-DbaServerAuditSpecification

Examples

Copies all server audits from sqlserver2014a to sqlcluster using Windows credentials to connect. If audits with the same name exist on sqlcluster, they will be skipped.

Copy-DbaServerAuditSpecification -Source sqlserver2014a -Destination sqlcluster

Copies a single audit, the tg_noDbDrop audit from sqlserver2014a to sqlcluster using SQL credentials to connect to sqlserver2014a and Windows credentials to connect to sqlcluster. If an audit specification with the same name exists on sqlcluster, it will be dropped and recreated because -Force was used.

Copy-DbaServerAuditSpecification -Source sqlserver2014a -Destination sqlcluster -ServerAuditSpecification tg_noDbDrop -SourceSqlCredential $cred -Force

Shows what would happen if the command were executed using force.

Copy-DbaServerAuditSpecification -Source sqlserver2014a -Destination sqlcluster -WhatIf -Force

Author

This command was created by Chrissy LeMaire. You can find Chrissy on Twitter and his blog.