Thor Logo dbatools

Add-DbaInstanceList

View Source
the dbatools team + Claude
Windows, Linux, macOS

Synopsis

Adds one or more SQL Server instances to the user-maintained autocomplete list.

Description

Adds SQL Server instance names to a persistent list that pre-populates the tab completion
cache for the -SqlInstance parameter across all dbatools commands. This allows users to
have their frequently used instances available for autocomplete in their PowerShell
terminal without needing to connect to them first.

The instance list is stored using the dbatools configuration system. Use -Register to
persist the list across PowerShell sessions.

Instances can also be pre-loaded at module import time by setting the
$env:DBATOOLS_KNOWN_INSTANCES environment variable to a comma-separated list of instance
names in your PowerShell profile.

Syntax

Add-DbaInstanceList
    [-SqlInstance] <String[]>
    [-Register]
    [[-Scope] {UserDefault | UserMandatory | SystemDefault | SystemMandatory | FileUserLocal | FileUserShared | FileSystem}]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Add-DbaInstanceList -SqlInstance "sql01", "sql02\dev"

Adds sql01 and sql02\dev to the autocomplete instance list for the current session.

Example: 2
PS C:\> Add-DbaInstanceList -SqlInstance "sql01" -Register

Adds sql01 to the autocomplete instance list and persists it across PowerShell sessions.

Example: 3
PS C:\> "sql01", "sql02" | Add-DbaInstanceList -Register

Adds two instances to the list via pipeline and persists them across sessions.

Required Parameters

-SqlInstance

The SQL Server instance name or names to add to the autocomplete list.
Accepts pipeline input.

PropertyValue
Alias
RequiredTrue
Pipelinetrue (ByValue, ByPropertyName)
Default Value

Optional Parameters

-Register

Persists the instance list to disk so it is available in future PowerShell sessions.
Without this switch, the list only exists for the current session.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-Scope

Determines where the persistent configuration is stored when using -Register.
UserDefault stores the setting for the current user only.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueUserDefault

Outputs

None

This command updates the autocomplete cache but does not output any objects to the pipeline. Use Get-DbaInstanceList to retrieve the configured instance names.