Showing posts with label SQLPS Set Database to Simple recovery. Show all posts
Showing posts with label SQLPS Set Database to Simple recovery. Show all posts

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()
}