< Back
Export-DbaSpConfigure
Post
NAME Export-DbaSpConfigure
SYNOPSIS
Exports advanced sp_configure global configuration options to sql file.
SYNTAX
Export-DbaSpConfigure [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>
[[-SqlCredential] <Pscredential>] [[-Path] <String>] [[-FilePath] <String>] [-EnableException <Switch>]
[<CommonParameters>]
DESCRIPTION
Exports advanced sp_configure global configuration options to sql file.
PARAMETERS
-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
-FilePath [<String>]
Specifies the full file path of the output file.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Path [<String>]
Specifies the directory where the file or files will be exported.
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 [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target SQL Server instance or instances. This can be a collection and receive pipeline input.
You must have sysadmin access if needs to set 'show advanced options' to 1 and server version must be SQL
Server version 2005 or higher.
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
A DbaInstanceParameter representing an array of SQL Server instances.
OUTPUTS
Creates a new file for each SQL Server Instance
NOTES
Tags: SpConfig, Configure, Configuration
Author: Chrissy LeMaire (@cl), netnerds.net
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Export-DbaSpConfigure -SqlInstance sourceserver
Exports the SPConfigure settings on sourceserver. As no Path was defined outputs to My Documents folder with
default name format of Servername-MMDDYYYYhhmmss-sp_configure.sql
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Export-DbaSpConfigure -SqlInstance sourceserver -Path C:\\temp
Exports the SPConfigure settings on sourceserver to the directory C:\\temp using the default name format
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>$cred = Get-Credential sqladmin
PS C:\\> Export-DbaSpConfigure -SqlInstance sourceserver -SqlCredential $cred -Path C:\\temp\\sp_configure.sql
Exports the SPConfigure settings on sourceserver to the file C:\\temp\\sp_configure.sql. Uses SQL Authentication to
connect. Will require SysAdmin rights if needs to set 'show advanced options'
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>'Server1', 'Server2' | Export-DbaSpConfigure -Path C:\\temp\\configure.sql
Exports the SPConfigure settings for Server1 and Server2 using pipeline. As more than 1 Server adds prefix of
Servername and date to the file name and saves to file like C:\\temp\\Servername-MMDDYYYYhhmmss-configure.sql
RELATED LINKS
https://dbatools.io/Export-DbaSpConfigure
SYNOPSIS
Exports advanced sp_configure global configuration options to sql file.
SYNTAX
Export-DbaSpConfigure [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>
[[-SqlCredential] <Pscredential>] [[-Path] <String>] [[-FilePath] <String>] [-EnableException <Switch>]
[<CommonParameters>]
DESCRIPTION
Exports advanced sp_configure global configuration options to sql file.
PARAMETERS
-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
-FilePath [<String>]
Specifies the full file path of the output file.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Path [<String>]
Specifies the directory where the file or files will be exported.
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 [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target SQL Server instance or instances. This can be a collection and receive pipeline input.
You must have sysadmin access if needs to set 'show advanced options' to 1 and server version must be SQL
Server version 2005 or higher.
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
A DbaInstanceParameter representing an array of SQL Server instances.
OUTPUTS
Creates a new file for each SQL Server Instance
NOTES
Tags: SpConfig, Configure, Configuration
Author: Chrissy LeMaire (@cl), netnerds.net
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Export-DbaSpConfigure -SqlInstance sourceserver
Exports the SPConfigure settings on sourceserver. As no Path was defined outputs to My Documents folder with
default name format of Servername-MMDDYYYYhhmmss-sp_configure.sql
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Export-DbaSpConfigure -SqlInstance sourceserver -Path C:\\temp
Exports the SPConfigure settings on sourceserver to the directory C:\\temp using the default name format
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>$cred = Get-Credential sqladmin
PS C:\\> Export-DbaSpConfigure -SqlInstance sourceserver -SqlCredential $cred -Path C:\\temp\\sp_configure.sql
Exports the SPConfigure settings on sourceserver to the file C:\\temp\\sp_configure.sql. Uses SQL Authentication to
connect. Will require SysAdmin rights if needs to set 'show advanced options'
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>'Server1', 'Server2' | Export-DbaSpConfigure -Path C:\\temp\\configure.sql
Exports the SPConfigure settings for Server1 and Server2 using pipeline. As more than 1 Server adds prefix of
Servername and date to the file name and saves to file like C:\\temp\\Servername-MMDDYYYYhhmmss-configure.sql
RELATED LINKS
https://dbatools.io/Export-DbaSpConfigure