Author | Chrissy LeMaire (@cl), netnerds.net |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Copy-DbaPolicyManagement on GitHub.
Want to see the Bill Of Health for this command? Check out Copy-DbaPolicyManagement.
Migrates SQL Policy Based Management Objects, including both policies and conditions.
By default, all policies and conditions are copied. If an object already exist on the destination, it will be skipped unless -Force is used.
The -Policy and -Condition parameters are auto-populated for command-line completion and can be used to copy only specific objects.
Copy-DbaPolicyManagement
[-Source] <DbaInstanceParameter>
[[-SourceSqlCredential] <PSCredential>]
[-Destination] <DbaInstanceParameter[]>
[[-DestinationSqlCredential] <PSCredential>]
[[-Policy] <Object[]>]
[[-ExcludePolicy] <Object[]>]
[[-Condition] <Object[]>]
[[-ExcludeCondition] <Object[]>]
[-Force]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Copy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster
Copies all policies and conditions from sqlserver2014a to sqlcluster, using Windows credentials.
PS C:\> Copy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster -SourceSqlCredential $cred
Copies all policies and conditions from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster.
PS C:\> Copy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster -WhatIf
Shows what would happen if the command were executed.
PS C:\> Copy-DbaPolicyManagement -Source sqlserver2014a -Destination sqlcluster -Policy 'xp_cmdshell must be disabled'
Copies only one policy, 'xp_cmdshell must be disabled' from sqlserver2014a to sqlcluster. No conditions are migrated.
Source SQL Server.You must have sysadmin access and server version must be SQL Server version 2008 or higher.
Alias | |
Required | True |
Pipeline | false |
Default Value |
Destination Sql Server. You must have sysadmin access and server version must be SQL Server version 2008 or higher.
Alias | |
Required | True |
Pipeline | false |
Default Value |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The policy(ies) to process - this list is auto-populated from the server. If unspecified, all policies will be processed.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The policy(ies) to exclude - this list is auto-populated from the server
Alias | |
Required | False |
Pipeline | false |
Default Value |
The condition(s) to process - this list is auto-populated from the server. If unspecified, all conditions will be processed.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The condition(s) to exclude - this list is auto-populated from the server
Alias | |
Required | False |
Pipeline | false |
Default Value |
If policies exists on destination server, it will be dropped and recreated.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Shows what would happen if the command were to run. No actions are actually performed.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts you for confirmation before executing any changing operations within the command.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |