Skip to content

Instantly share code, notes, and snippets.

@asvignesh
Created May 9, 2019 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asvignesh/8deeed60e04cc62dfc5ab514a8bcd4eb to your computer and use it in GitHub Desktop.
Save asvignesh/8deeed60e04cc62dfc5ab514a8bcd4eb to your computer and use it in GitHub Desktop.
Powershell Script to change the recovery model of the databases to FULL
$dbs = Get-SqlDatabase -ServerInstance NW1\CLUST2
foreach ($database in $dbs | where { $_.IsSystemObject -eq $False })
{
$dbName = $database.Name
$sql = @"
USE [master]
GO
ALTER DATABASE [$dbName] SET RECOVERY FULL WITH NO_WAIT
GO
"@
invoke-sqlcmd $sql -ServerInstance NW1\CLUST2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment