File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ function Set-SQLLogFiles
2+ {
3+ <#
4+ . Synopsis
5+ Sets the number of Log files for a single or group of SQL Servers
6+
7+ . DESCRIPTION
8+ Uses SMO to set the number of Log files for a single or group of SQL Servers
9+
10+ . PARAMETER Instances
11+ The SQL Server Instance or an array of instances to change
12+
13+ . PARAMETER Number
14+ The number of logfiles to set
15+
16+ . EXAMPLE
17+ Set-SQLLogFiles -instances Fade2Black -Number 20
18+
19+ Sets the number of SQL Server log files to 20 on the instance Fade2Black
20+ . EXAMPLE
21+ $Servers = 'Fade2Black','JusticeForAll','MasterOfPuppets'
22+ Set-SQLLogFiles -instances $Servers -Number 20
23+
24+ Sets the number of SQL Server log files to 20 on the instances 'Fade2Black','JusticeForAll','MasterOfPuppets'
25+ . NOTES
26+ Author - Rob Sewell SQLDBAWithABeard.com
27+ #>
28+ param (
29+ [object ]$instances ,
30+ [ValidateRange (0 , 99 )]
31+ [int ]$Number
32+ )
33+ [void ][reflection.assembly ]::LoadWithPartialName( ' Microsoft.SqlServer.Smo' )
34+ foreach ($Server in $Instances )
35+ {
36+ try
37+ {
38+ $srv = New-Object Microsoft.SqlServer.Management.Smo.Server $server
39+ $srv.Settings.NumberOfLogFiles = $Number
40+ $srv.Alter ()
41+ }
42+ catch
43+ {
44+ Write-Warning " Eailed to set Log Fiels on $Server - Run `$ error[0]|fl -force to find the error"
45+ continue
46+ }
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments