dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Set-DbaStartupParameter

Sets the Startup Parameters for a SQL Server instance. For full details of what each parameter does, please refer to this MSDN article.

Examples

To configure the SQL Instance server1\instance1 to startup up in Single User mode at next startup

Set-DbaStartupParameter -SqlServer server1\instance1 -SingleUser

To configure the SQL Instance sql2016 to IncreasedExtents = True (-E)

Set-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents

To show what would happen if you attempted to configure the SQL Instance sql2016 to IncreasedExtents = False (no -E)

Set-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents:$false -WhatIf

To append Trace Flags 8032 and 8048 to the startup parameters

Set-DbaStartupParameter -SqlServer server1\instance1 -SingleUser -TraceFlags 8032,8048

To remove all trace flags and set SinguleUser to false

Set-DbaStartupParameter -SqlServer sql2016 -SingleUser:$false -TraceFlagsOverride

To set Trace Flags 8032 and 8048 to the startup parameters, removing any existing Trace Flags

Set-DbaStartupParameter -SqlServer server1\instance1 -SingleUser -TraceFlags 8032,8048 -TraceFlagsOverride

In this example below, we take a copy of the existing startup configuration of server1\instance1. We then change the startup parameters ahead of some work. After the work has been completed, we can push the original startup parameters back to server1\instance1 and resume normal operation.

$StartupConfig = Get-DbaStartupParameter -SqlServer server1\instance1
Set-DbaStartupParameter -SqlServer server1\instance1 -SingleUser -NoLoggingToWinEvents # then do stuff
Set-DbaStartupParameter -SqlServer server1\instance1 -StartUpConfig $StartUpConfig

Screenshots

This screenshot can look intimidating but we intentionally included a few prompts and information.

Get-Help

From PowerShell, execute Get-Help Set-DbaStartupParameter -Detailed for more information on this function.

Source Code

Want to see the source code? View Set-DbaStartupParameter.ps1 on GitHub
 

Related commands