Author | Chrissy LeMaire (@cl), netnerds.net |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Export-DbaRegServer on GitHub.
Want to see the Bill Of Health for this command? Check out Export-DbaRegServer.
Exports registered servers and registered server groups to file
Exports registered servers and registered server groups to file
Export-DbaRegServer
[[-SqlInstance] <DbaInstanceParameter[]>]
[[-SqlCredential] <PSCredential>]
[[-InputObject] <Object[]>]
[[-Path] <String>]
[[-FilePath] <FileInfo>]
[[-CredentialPersistenceType] <String>]
[[-Group] <Object[]>]
[[-ExcludeGroup] <Object[]>]
[-Overwrite]
[-EnableException]
[<CommonParameters>]
PS C:\> Export-DbaRegServer -SqlInstance sql2008
Exports all Registered Server and Registered Server Groups on sql2008 to an automatically generated file name in the current directory
PS C:\> Get-DbaRegServer -SqlInstance sql2008, sql2012 | Export-DbaRegServer
Exports all registered servers on sql2008 and sql2012. Warning - each one will have its own individual file. Consider piping groups.
PS C:\> Get-DbaRegServerGroup -SqlInstance sql2008, sql2012 | Export-DbaRegServer
Exports all registered servers on sql2008 and sql2012, organized by group.
The target SQL Server instance or instances.
Alias | |
Required | False |
Pipeline | false |
Default Value |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Accepts registered server or server group objects from Get-DbaRegServer, Get-DbaRegServerGroup, or custom objects via pipeline.
Use this to export specific servers or groups that have been filtered or modified before export.
For custom objects, requires a ServerName column with optional Name, Description, and Group columns.
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
Specifies the directory where the exported registered server files will be saved.
Uses the dbatools default export directory if not specified, typically your user profile's Documents folder.
Automatically generates timestamped filenames when exporting multiple servers or groups.
Alias | |
Required | False |
Pipeline | false |
Default Value | (Get-DbatoolsConfigValue -FullName 'Path.DbatoolsExport') |
Specifies the complete file path for the exported registered server file, including filename and extension.
Must end with .xml or .regsrvr extension to be compatible with SQL Server Management Studio imports.
When exporting multiple groups, the group name is automatically appended to avoid file conflicts.
Alias | OutFile,FileName |
Required | False |
Pipeline | false |
Default Value |
Controls how login credentials are stored in the exported registered server file.
Use 'PersistLoginName' to save usernames only, or 'PersistLoginNameAndPassword' to include passwords for automated connections.
Defaults to 'None' for security, requiring manual credential entry when connecting.
Alias | |
Required | False |
Pipeline | false |
Default Value | None |
Accepted Values | None,PersistLoginName,PersistLoginNameAndPassword |
Filters export to include only registered servers from the specified server group names.
Use this when you want to export servers from specific organizational groups like 'Production', 'Development', or 'QA'.
Accepts wildcards and multiple group names to export several groups in a single operation.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Excludes registered servers from the specified server group names during export.
Useful when exporting most groups but need to skip sensitive environments like 'Production' or 'Customer-Facing'.
Can be combined with the Group parameter to fine-tune which servers are included in the export.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Allows the function to replace an existing file at the specified FilePath location.
Required when the target export file already exists, preventing accidental data loss.
Without this switch, the function will stop with an error if the destination file is found.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |