I love SQL Server. No matter how long you play with it, there is always a little setting here and there that I did not know about, or had forgotten over the years. This morning Mr Denny clued me into one of these on his blog (via Twitter). The setting was the number of SQL server error logs to retain. He showed us how to set this in SSMS and via a T-SQL change to the registry.
My first thought as I read this was “how can I do this in PowerShell?”.
Sometimes it is easy, sometimes it is harder than anticipated. In this case, it was way to easy, it took me all of 2 minutes looking at the SMO Server object to find a wonderful little property, NumberOfLogFiles. This led me to write this little script that I am going to add into my standard Post deployment configuration script:
$server = gss -computername SERVER1
$server.NumberOfLogFiles = 20
gss is an alias to my own profile loaded function that simply returns an SMO object referencing the server I am looking at. Of course, as Mr Denny states, the number you want to configure will vary from install to install, so make sure you use the appropriate value.
Thanks for reading.