Thor Logo dbatools

Import-DbatoolsConfig

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

Synopsis

Imports dbatools configuration settings from JSON files or default module paths.

Description

Loads dbatools configuration settings from JSON files or retrieves module-specific settings from default configuration locations. This lets you restore saved dbatools preferences, share standardized settings across your team, or apply configuration baselines to multiple servers. You can import from local files, web URLs, or raw JSON strings, with optional filtering to selectively apply only the settings you need.

Syntax

Import-DbatoolsConfig -Path <String[]>
    [-IncludeFilter <String[]>]
    [-ExcludeFilter <String[]>]
    [-Peek]
    [-EnableException]
    [<CommonParameters>]

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

 

Examples

 

Example: 1
PS C:\> Import-DbatoolsConfig -Path '.\config.json'

Imports the configuration stored in ‘.\config.json’

Example: 2
PS C:\> Import-DbatoolsConfig -ModuleName message

Imports all the module specific settings that have been persisted in any of the default file system paths.

Required Parameters

-Path

Specifies the path to JSON configuration files, web URLs, or raw JSON strings to import settings from.
Use this to restore saved dbatools preferences, apply team-standard configurations, or load settings from remote locations.
Accepts local file paths, HTTP/HTTPS URLs, or direct JSON content as strings.

PropertyValue
Alias
RequiredTrue
Pipelinetrue (ByValue)
Default Value
-ModuleName

Specifies which dbatools module’s configuration settings to import from default system locations.
Use this to restore module-specific settings that were previously saved using Export-DbatoolsConfig.
Common modules include ‘message’ for logging preferences and ‘sql’ for connection defaults.

PropertyValue
Alias
RequiredTrue
Pipelinefalse
Default Value

Optional Parameters

-ModuleVersion

Specifies which version of the module configuration schema to load when importing persisted settings.
Defaults to version 1, which works for most scenarios unless you’re working with legacy configuration exports.
Only change this if you’re importing settings exported with a different version of dbatools.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value1
-Scope

Controls which configuration storage locations to search when importing module settings.
Options include FileUserLocal (user profile), FileUserShared (shared user settings), and FileSystem (system-wide).
User settings override system settings when the same configuration exists in multiple locations.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFileUserLocal, FileUserShared, FileSystem
-IncludeFilter

Specifies wildcard patterns to selectively import only matching configuration items from the source.
Use this to import specific settings like ‘sql.connection.’ for connection-related configs or ’logging.’ for logging preferences.
Supports PowerShell -like wildcard matching with * and ? characters.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-ExcludeFilter

Specifies wildcard patterns to exclude specific configuration items during import.
Use this to skip sensitive settings like credentials or environment-specific paths when sharing configurations.
Applied after IncludeFilter, allowing you to include a category but exclude specific items within it.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Peek

Returns the configuration items that would be imported without actually applying them to your session.
Use this to preview configuration changes before applying them, especially when importing from unfamiliar sources.
Helpful for validating configuration files and understanding what settings will be modified.

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