< Back
Set-DbaStartupParameter
Post
NAME Set-DbaStartupParameter
SYNOPSIS
Sets the Startup Parameters for a SQL Server instance
SYNTAX
Set-DbaStartupParameter [-SqlInstance] <DbaInstanceParameter> [[-SqlCredential] <Pscredential>] [[-Credential]
<Pscredential>] [[-MasterData] <String>] [[-MasterLog] <String>] [[-ErrorLog] <String>] [[-TraceFlag]
<System.String[]>] [-CommandPromptStart <Switch>] [-MinimalStart <Switch>] [[-MemoryToReserve] <Int>] [-SingleUser
<Switch>] [[-SingleUserDetails] <String>] [-NoLoggingToWinEvents <Switch>] [-StartAsNamedInstance <Switch>]
[-DisableMonitoring <Switch>] [-IncreasedExtents <Switch>] [-TraceFlagOverride <Switch>] [[-StartupConfig]
<System.Object>] [-Offline <Switch>] [-Force <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Modifies the startup parameters for a specified SQL Server Instance
For full details of what each parameter does, please refer to this MSDN article -
https://msdn.microsoft.com/en-us/librar ... .105).aspx
PARAMETERS
-CommandPromptStart [<Switch>]
Shortens startup time when starting SQL Server from the command prompt. Typically, the SQL Server Database
Engine starts as a service by calling the Service Control Manager.
Because the SQL Server Database Engine does not start as a service when starting from the command prompt
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Credential [<Pscredential>]
Windows Credential with permission to log on to the server running the SQL instance
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-DisableMonitoring [<Switch>]
Disables the following monitoring features:
SQL Server performance monitor counters
Keeping CPU time and cache-hit ratio statistics
Collecting information for the DBCC SQLPERF command
Collecting information for some dynamic management views
Many extended-events event points
** Warning *\\* When you use the -x startup option, the information that is available for you to diagnose
performance and functional problems with SQL Server is greatly reduced.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ErrorLog [<String>]
Path to the SQL Server error log file
Will be ignored if SqlInstance is offline or the Offline switch is set. To override this behaviour use the
Force switch. This is to ensure you understand the risk as we cannot validate the path if the instance is
offline
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Force [<Switch>]
By default we test the values passed in via MasterData, MasterLog, ErrorLog
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-IncreasedExtents [<Switch>]
Increases the number of extents that are allocated for each file in a filegroup.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MasterData [<String>]
Path to the data file for the Master database
Will be ignored if SqlInstance is offline or the Offline switch is set. To override this behaviour use the
Force switch. This is to ensure you understand the risk as we cannot validate the path if the instance is
offline
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MasterLog [<String>]
Path to the log file for the Master database
Will be ignored if SqlInstance is offline or the Offline switch is set. To override this behaviour use the
Force switch. This is to ensure you understand the risk as we cannot validate the path if the instance is
offline
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MemoryToReserve [<Int>]
Specifies an integer number of megabytes (MB) of memory that SQL Server will leave available for memory
allocations within the SQL Server process,
but outside the SQL Server memory pool. The memory outside of the memory pool is the area used by SQL Server
for loading items such as extended procedure .dll files,
the OLE DB providers referenced by distributed queries, and automation objects referenced in Transact-SQL
statements. The default is 256 MB.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MinimalStart [<Switch>]
Starts an instance of SQL Server with minimal configuration. This is useful if the setting of a configuration
value (for example, over-committing memory) has
prevented the server from starting. Starting SQL Server in minimal configuration mode places SQL Server in
single-user mode
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-NoLoggingToWinEvents [<Switch>]
Don't use Windows Application events log
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Offline [<Switch>]
Setting this switch will try perform the requested actions without connect to the SQL Server Instance, this
will speed things up if you know the Instance is offline.
When working offline, path inputs (MasterData, MasterLog and ErrorLog) will be ignored, unless Force is
specified
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SingleUser [<Switch>]
Start Sql Server in single user mode
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SingleUserDetails [<String>]
The username for single user
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<DbaInstanceParameter>]
The SQL Server instance to be modified
If the Sql Instance is offline path parameters will be ignored as we cannot test the instance's access to the
path. If you want to force this to work then please use the Force switch
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-StartAsNamedInstance [<Switch>]
Allows you to start a named instance of SQL Server
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-StartupConfig [<System.Object>]
Pass in a previously saved SQL Instance startup config
using this parameter will set TraceFlagOverride to true, so existing Trace Flags will be overridden
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-TraceFlag [<System.String[]>]
A comma separated list of TraceFlags to be applied at SQL Server startup
By default these will be appended to any existing trace flags set
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-TraceFlagOverride [<Switch>]
Overrides the default behaviour and replaces any existing trace flags. If not trace flags specified will just
remove existing ones
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: Startup, Parameter, Configure
Author: Stuart Moore (@napalmgram), stuart-moore.com
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser
Will configure the SQL Instance server1\\instance1 to startup up in Single User mode at next startup
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents
Will configure the SQL Instance sql2016 to IncreasedExtents = True (-E)
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents:$false -WhatIf
Shows what would happen if you attempted to configure the SQL Instance sql2016 to IncreasedExtents = False (no -E)
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance server1\\instance1 -TraceFlag 8032,8048
This will append Trace Flags 8032 and 8048 to the startup parameters
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -SingleUser:$false -TraceFlagOverride
This will remove all trace flags and set SingleUser to false
-------------------------- EXAMPLE 6 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -TraceFlag 8032,8048 -TraceFlagOverride
This will set Trace Flags 8032 and 8048 to the startup parameters, removing any existing Trace Flags
-------------------------- EXAMPLE 7 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -SingleUser:$false -TraceFlagOverride -Offline
This will remove all trace flags and set SingleUser to false from an offline instance
-------------------------- EXAMPLE 8 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -ErrorLog c:\\Sql\\ -Offline
This will attempt to change the ErrorLog path to c:\\sql\\. However, with the offline switch this will not happen.
To force it, use the -Force switch like so:
Set-DbaStartupParameter -SqlInstance sql2016 -ErrorLog c:\\Sql\\ -Offline -Force
-------------------------- EXAMPLE 9 --------------------------
PS C:\\>$StartupConfig = Get-DbaStartupParameter -SqlInstance server1\\instance1
PS C:\\> Set-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -NoLoggingToWinEvents
PS C:\\> #Restart your SQL instance with the tool of choice
PS C:\\> #Do Some work
PS C:\\> Set-DbaStartupParameter -SqlInstance server1\\instance1 -StartupConfig $StartupConfig
PS C:\\> #Restart your SQL instance with the tool of choice and you're back to normal
In this example 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
RELATED LINKS
https://dbatools.io/Set-DbaStartupParameter
SYNOPSIS
Sets the Startup Parameters for a SQL Server instance
SYNTAX
Set-DbaStartupParameter [-SqlInstance] <DbaInstanceParameter> [[-SqlCredential] <Pscredential>] [[-Credential]
<Pscredential>] [[-MasterData] <String>] [[-MasterLog] <String>] [[-ErrorLog] <String>] [[-TraceFlag]
<System.String[]>] [-CommandPromptStart <Switch>] [-MinimalStart <Switch>] [[-MemoryToReserve] <Int>] [-SingleUser
<Switch>] [[-SingleUserDetails] <String>] [-NoLoggingToWinEvents <Switch>] [-StartAsNamedInstance <Switch>]
[-DisableMonitoring <Switch>] [-IncreasedExtents <Switch>] [-TraceFlagOverride <Switch>] [[-StartupConfig]
<System.Object>] [-Offline <Switch>] [-Force <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Modifies the startup parameters for a specified SQL Server Instance
For full details of what each parameter does, please refer to this MSDN article -
https://msdn.microsoft.com/en-us/librar ... .105).aspx
PARAMETERS
-CommandPromptStart [<Switch>]
Shortens startup time when starting SQL Server from the command prompt. Typically, the SQL Server Database
Engine starts as a service by calling the Service Control Manager.
Because the SQL Server Database Engine does not start as a service when starting from the command prompt
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Credential [<Pscredential>]
Windows Credential with permission to log on to the server running the SQL instance
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-DisableMonitoring [<Switch>]
Disables the following monitoring features:
SQL Server performance monitor counters
Keeping CPU time and cache-hit ratio statistics
Collecting information for the DBCC SQLPERF command
Collecting information for some dynamic management views
Many extended-events event points
** Warning *\\* When you use the -x startup option, the information that is available for you to diagnose
performance and functional problems with SQL Server is greatly reduced.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ErrorLog [<String>]
Path to the SQL Server error log file
Will be ignored if SqlInstance is offline or the Offline switch is set. To override this behaviour use the
Force switch. This is to ensure you understand the risk as we cannot validate the path if the instance is
offline
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Force [<Switch>]
By default we test the values passed in via MasterData, MasterLog, ErrorLog
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-IncreasedExtents [<Switch>]
Increases the number of extents that are allocated for each file in a filegroup.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MasterData [<String>]
Path to the data file for the Master database
Will be ignored if SqlInstance is offline or the Offline switch is set. To override this behaviour use the
Force switch. This is to ensure you understand the risk as we cannot validate the path if the instance is
offline
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MasterLog [<String>]
Path to the log file for the Master database
Will be ignored if SqlInstance is offline or the Offline switch is set. To override this behaviour use the
Force switch. This is to ensure you understand the risk as we cannot validate the path if the instance is
offline
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MemoryToReserve [<Int>]
Specifies an integer number of megabytes (MB) of memory that SQL Server will leave available for memory
allocations within the SQL Server process,
but outside the SQL Server memory pool. The memory outside of the memory pool is the area used by SQL Server
for loading items such as extended procedure .dll files,
the OLE DB providers referenced by distributed queries, and automation objects referenced in Transact-SQL
statements. The default is 256 MB.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-MinimalStart [<Switch>]
Starts an instance of SQL Server with minimal configuration. This is useful if the setting of a configuration
value (for example, over-committing memory) has
prevented the server from starting. Starting SQL Server in minimal configuration mode places SQL Server in
single-user mode
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-NoLoggingToWinEvents [<Switch>]
Don't use Windows Application events log
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Offline [<Switch>]
Setting this switch will try perform the requested actions without connect to the SQL Server Instance, this
will speed things up if you know the Instance is offline.
When working offline, path inputs (MasterData, MasterLog and ErrorLog) will be ignored, unless Force is
specified
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SingleUser [<Switch>]
Start Sql Server in single user mode
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SingleUserDetails [<String>]
The username for single user
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<DbaInstanceParameter>]
The SQL Server instance to be modified
If the Sql Instance is offline path parameters will be ignored as we cannot test the instance's access to the
path. If you want to force this to work then please use the Force switch
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-StartAsNamedInstance [<Switch>]
Allows you to start a named instance of SQL Server
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-StartupConfig [<System.Object>]
Pass in a previously saved SQL Instance startup config
using this parameter will set TraceFlagOverride to true, so existing Trace Flags will be overridden
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-TraceFlag [<System.String[]>]
A comma separated list of TraceFlags to be applied at SQL Server startup
By default these will be appended to any existing trace flags set
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-TraceFlagOverride [<Switch>]
Overrides the default behaviour and replaces any existing trace flags. If not trace flags specified will just
remove existing ones
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: Startup, Parameter, Configure
Author: Stuart Moore (@napalmgram), stuart-moore.com
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser
Will configure the SQL Instance server1\\instance1 to startup up in Single User mode at next startup
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents
Will configure the SQL Instance sql2016 to IncreasedExtents = True (-E)
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -IncreasedExtents:$false -WhatIf
Shows what would happen if you attempted to configure the SQL Instance sql2016 to IncreasedExtents = False (no -E)
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance server1\\instance1 -TraceFlag 8032,8048
This will append Trace Flags 8032 and 8048 to the startup parameters
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -SingleUser:$false -TraceFlagOverride
This will remove all trace flags and set SingleUser to false
-------------------------- EXAMPLE 6 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -TraceFlag 8032,8048 -TraceFlagOverride
This will set Trace Flags 8032 and 8048 to the startup parameters, removing any existing Trace Flags
-------------------------- EXAMPLE 7 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -SingleUser:$false -TraceFlagOverride -Offline
This will remove all trace flags and set SingleUser to false from an offline instance
-------------------------- EXAMPLE 8 --------------------------
PS C:\\>Set-DbaStartupParameter -SqlInstance sql2016 -ErrorLog c:\\Sql\\ -Offline
This will attempt to change the ErrorLog path to c:\\sql\\. However, with the offline switch this will not happen.
To force it, use the -Force switch like so:
Set-DbaStartupParameter -SqlInstance sql2016 -ErrorLog c:\\Sql\\ -Offline -Force
-------------------------- EXAMPLE 9 --------------------------
PS C:\\>$StartupConfig = Get-DbaStartupParameter -SqlInstance server1\\instance1
PS C:\\> Set-DbaStartupParameter -SqlInstance server1\\instance1 -SingleUser -NoLoggingToWinEvents
PS C:\\> #Restart your SQL instance with the tool of choice
PS C:\\> #Do Some work
PS C:\\> Set-DbaStartupParameter -SqlInstance server1\\instance1 -StartupConfig $StartupConfig
PS C:\\> #Restart your SQL instance with the tool of choice and you're back to normal
In this example 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
RELATED LINKS
https://dbatools.io/Set-DbaStartupParameter