Wednesday, March 14, 2012

SQL Powershell Set all DBs to Simple recovery

Simple recovery model has its place but here's an easy way to set it programatically

$DBinstanace = sqlserver:\sql\\
gci $DBinstanace\Databases| where {$_.RecoveryModel -like "Full"}|`
foreach {
$_.RecoveryModel = [Microsoft.SqlServer.Management.Smo.RecoveryModel]::Simple
$_.Alter()
}

No comments:

Post a Comment