Thor Logo dbatools

Export-DbatoolsConfig

View Source
Friedrich Weinmann (@FredWeinmann)
Windows, Linux, macOS

Synopsis

Exports dbatools module configuration settings to a JSON file for backup or migration.

Description

Exports dbatools configuration settings to a JSON file, allowing you to backup your current settings or migrate them to other machines. This function captures customized settings like connection timeouts, default database paths, and other module preferences that have been changed from their default values. You can export all settings or filter by specific modules, and optionally exclude settings that haven’t been modified from defaults.

Syntax

Export-DbatoolsConfig -FullName <String>
    [-OutPath] <String>
    [-SkipUnchanged]
    [-EnableException]
    [<CommonParameters>]

Export-DbatoolsConfig -Module <String>
    [[-Name] <String>]
    [-OutPath] <String>
    [-SkipUnchanged]
    [-EnableException]
    [<CommonParameters>]

Export-DbatoolsConfig -Config <Config[]>
    [-OutPath] <String>
    [-SkipUnchanged]
    [-EnableException]
    [<CommonParameters>]

Export-DbatoolsConfig -ModuleName <String>
    [-ModuleVersion <Int32>]
    [-Scope {UserDefault | UserMandatory | SystemDefault | SystemMandatory | FileUserLocal | FileUserShared | FileSystem}]
    [-SkipUnchanged]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbatoolsConfig | Export-DbatoolsConfig -OutPath '~/export.json'

Exports all current settings to json.

Example: 2
PS C:\> Export-DbatoolsConfig -Module message -OutPath '~/export.json' -SkipUnchanged

Exports all settings of the module ‘message’ that are no longer the original default values to json.

Required Parameters

-FullName

Specifies the complete configuration setting name to export, including the module prefix (e.g., ‘dbatools.path.dbatoolsdata’).
Use this when you need to export a specific configuration setting and know its exact full name.

PropertyValue
Alias
RequiredTrue
Pipelinefalse
Default Value
-Module

Filters configuration settings to export only those belonging to a specific dbatools module (e.g., ‘sql’, ‘path’, ‘message’).
Use this when you want to export all settings related to a particular functional area of dbatools rather than individual settings.

PropertyValue
Alias
RequiredTrue
Pipelinefalse
Default Value
-Config

Accepts configuration objects directly from Get-DbatoolsConfig for export to JSON.
Use this when you want to filter or manipulate configuration objects before export, typically in pipeline operations.

PropertyValue
Alias
RequiredTrue
Pipelinetrue (ByValue)
Default Value
-ModuleName

Exports module-specific configuration settings to predefined system locations rather than a custom path.
Only exports settings marked as ‘ModuleExport’ that have been modified from defaults, useful for creating standardized module configuration packages.

PropertyValue
Alias
RequiredTrue
Pipelinefalse
Default Value
-OutPath

Specifies the complete file path where the JSON configuration export will be saved, including the filename.
The parent directory must exist or the export will fail, and any existing file at this location will be overwritten.

PropertyValue
Alias
RequiredTrue
Pipelinefalse
Default Value

Optional Parameters

-Name

Specifies a pattern to match configuration setting names within the selected module, supporting wildcards.
Use this with the Module parameter to narrow down which settings to export when you don’t need all settings from a module.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value*
-ModuleVersion

Specifies the version number to include in the exported configuration filename when using ModuleName parameter.
Defaults to 1 and helps track different versions of module configuration exports for change management.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value1
-Scope

Determines where to save module configuration files when using ModuleName parameter - user profile, shared location, or system-wide.
Only file-based scopes are supported (registry scopes are blocked). Defaults to FileUserShared for cross-user accessibility.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFileUserShared
-SkipUnchanged

Excludes configuration settings that still have their original default values from the export.
Use this to create smaller backup files containing only your customized settings, making configuration migration more focused.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-EnableException

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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse