Hello Geeks,

This is the first blog of the part of blogs set I am going to write for next few months. I have been working on a centralized approach for Database Administration. I know this has been mostly the case for bigger organisations. This blog series will target DBAs who are finding difficult to manage multiple SQL instances without any centralised DBA maintenance and monitoring tools.

As a DBA it is assumed that the setup is always perfect and need not be changed over time. But, I have seen many instances where the standard setup of multiple servers is not following best practices. And it is up to the DBA to make these changes across the environment over time and again. In this blog I will take the example of a start-up trace flag which is essential to cut down the noise in the error log.

When is the last time you have considered to add 3226 as part of start-up parameter when installing a new instance? If you have a standard practice to include it, you have a better process than many other places. Trace flag 3226 is used to supress the success messages for backups. I will use this as an example in this post.

I can use either C# or Powershell to do this. I have seen many of the DBA inclined towards using Powershell. Personally I like C# .NET more. For this post I will use Powershell. First things first, to run the Powershell script on remote computer the powershell remoting should be enable on the remote computer. More details about Enable-PSremoting.

The following code takes two parameters

  1. Comma separated list of computers.
  2. Start-up parameter value to be set.

The script then gets the list of SQL instances installed on the computer. Then it adds the start-up parameter to each and every instance on the computer. It is intelligent enough to add the parameter as the last value in the parameter list.

 

AddStartupParam_Remote.ps1

The execution of the above script on a couple of machines looks like the following.

pstraceflag

The script has skipped adding the start-up parameter on COMP1 for default instance and on COMP2 for two named and a default instance. This is as the trace flag is already added.

This can be used for setting various other start-up parameters or by a simple tweak to set other registry parameters. But let me warn you, it is not a recommended way of changing things at registry level unless you are 100% sure about what you are changing.

 

Happy Learning,
Manu
Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook |
Follow me on Twitter | Follow me on FaceBook