commands

^

Get-DbaDbFileMapping

Author Chrissy LeMaire (@cl), netnerds.net , Andreas Jordan (@JordanOrdix), ordix.de
Availability Windows, Linux, macOS

 

Synopsis

Provides an easy way to build the FileMapping Hashtable for Restore-DbaDatabase from an existing database

Description

Provides an easy way to build the FileMapping Hashtable for Restore-DbaDatabase from an existing database

Syntax

Get-DbaDbFileMapping
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Database] <String[]>]
    [[-InputObject] <Database[]>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> $filemap = Get-DbaDbFileMapping -SqlInstance sql2016 -Database test
PS C:\> Get-ChildItem \\nas\db\backups\test | Restore-DbaDatabase -SqlInstance sql2019 -Database test -FileMapping $filemap.FileMapping

Restores test to sql2019 using the file structure built from the existing database on sql2016

Optional Parameters

-SqlInstance

The target SQL Server instance or instances. This can be a collection and receive pipeline input.

Alias
Required False
Pipeline true (ByValue)
Default Value
-SqlCredential

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
-Database

The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.

Alias
Required False
Pipeline false
Default Value
-InputObject

Database object piped in from Get-DbaDatabase

Alias
Required False
Pipeline true (ByValue)
Default Value
-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.

Alias
Required False
Pipeline false
Default Value False

 

Want to see the source code for this command? Check out Get-DbaDbFileMapping on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaDbFileMapping.