Author | Viorel Ciucu (@viorelciucu), cviorel.com |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Set-DbaDbRecoveryModel on GitHub.
Want to see the Bill Of Health for this command? Check out Set-DbaDbRecoveryModel.
Set-DbaDbRecoveryModel sets the Recovery Model.
Set-DbaDbRecoveryModel sets the Recovery Model for all databases except TEMPDB.
Set-DbaDbRecoveryModel
[-SqlCredential <PSCredential>]
-RecoveryModel <String>
[-Database <Object[]>]
[-ExcludeDatabase <Object[]>]
[-AllDatabases]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-DbaDbRecoveryModel -SqlInstance <DbaInstanceParameter[]>
[-SqlCredential <PSCredential>]
-RecoveryModel <String>
[-Database <Object[]>]
[-ExcludeDatabase <Object[]>]
[-AllDatabases]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-DbaDbRecoveryModel
[-SqlCredential <PSCredential>]
-RecoveryModel <String>
[-Database <Object[]>]
[-ExcludeDatabase <Object[]>]
[-AllDatabases]
[-EnableException]
-InputObject <Database[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Set-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel BulkLogged -Database model -Confirm:$true -Verbose
Sets the Recovery Model to BulkLogged for database [model] on SQL Server instance sql2014. User is requested to confirm the action.
PS C:\> Get-DbaDatabase -SqlInstance sql2014 -Database TestDB | Set-DbaDbRecoveryModel -RecoveryModel Simple -Confirm:$false
Sets the Recovery Model to Simple for database [TestDB] on SQL Server instance sql2014. Confirmation is not required.
PS C:\> Set-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel Simple -Database TestDB -Confirm:$false
Sets the Recovery Model to Simple for database [TestDB] on SQL Server instance sql2014. Confirmation is not required.
PS C:\> Set-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel Simple -AllDatabases -Confirm:$false
Sets the Recovery Model to Simple for ALL user and system databases (except TEMPDB) on SQL Server instance sql2014. Runs without asking for confirmation.
PS C:\> Set-DbaDbRecoveryModel -SqlInstance sql2014 -RecoveryModel BulkLogged -Database TestDB1, TestDB2 -Confirm:$false -Verbose
Sets the Recovery Model to BulkLogged for [TestDB1] and [TestDB2] databases on SQL Server instance sql2014. Runs without asking for confirmation.
The target SQL Server instance or instances.
Alias | |
Required | True |
Pipeline | false |
Default Value |
Recovery Model to be set. Valid options are 'Simple', 'Full', 'BulkLogged'
Details about the recovery models can be found here:
https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/recovery-models-sql-server
Alias | |
Required | True |
Pipeline | false |
Default Value | |
Accepted Values | Simple,Full,BulkLogged |
A collection of databases (such as returned by Get-DbaDatabase)
Alias | |
Required | True |
Pipeline | true (ByValue) |
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 database(s) to process - this list is auto-populated from the server. if unspecified, all databases will be processed.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The database(s) to exclude - this list is auto-populated from the server
Alias | |
Required | False |
Pipeline | false |
Default Value |
This is a parameter that was included for safety, so you don't accidentally set options on all databases without specifying
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 |
If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts for confirmation. For example:
Are you sure you want to perform this action?
Performing the operation "ALTER DATABASE [model] SET RECOVERY Full" on target "[model] on WERES14224".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Alias | cf |
Required | False |
Pipeline | false |
Default Value |