Created
May 19, 2015 12:32
-
-
Save wpsmith/4c7d0c7209da0a55f1ec to your computer and use it in GitHub Desktop.
PowerShell: Set AutoGrowth for SQL Server cycling through the individual filegroups as well as excluding system databases.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null | |
$server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") "localhost" | |
$databases = $server.Databases; | |
foreach ($db in $databases ) { | |
#Set Log File growth | |
if ($db.Status -eq 'Normal' -and -$db.IsSystemObject -eq $false) { | |
$l = $db.LogFiles[0] | |
$l.GrowthType = "KB" | |
$l.Growth = "51200" | |
$l.Alter(); | |
$df = $db.FileGroups | |
foreach($fg in $df){ | |
foreach ($f in $fg.Files) { | |
$f.GrowthType = "KB"; | |
$f.Growth = "102400" | |
$f.Alter(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment