commands

^

Measure-DbaDiskSpaceRequirement

Author Pollus Brodeur (@pollusb)
Availability Windows, Linux, macOS

 

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

Synopsis

Calculate the space needed to copy and possibly replace a database from one SQL server to another.

Description

Returns a file list from source and destination where source file may overwrite destination. Complex scenarios where a new file may exist is taken into account. This command will accept a hash object in pipeline with the following keys: Source, SourceDatabase, Destination. Using this command will provide a way to prepare before a complex migration with multiple databases from different sources and destinations.

Syntax

Measure-DbaDiskSpaceRequirement
    [-Source] <DbaInstanceParameter>
    [-Database] <String>
    [[-SourceSqlCredential] <PSCredential>]
    [-Destination] <DbaInstanceParameter>
    [[-DestinationDatabase] <String>]
    [[-DestinationSqlCredential] <PSCredential>]
    [[-Credential] <PSCredential>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Measure-DbaDiskSpaceRequirement -Source INSTANCE1 -Database DB1 -Destination INSTANCE2

Calculate space needed for a simple migration with one database with the same name at destination.

Example: 2
PS C:\> @(
>> [PSCustomObject]@{Source='SQL1';Destination='SQL2';Database='DB1'},
>> [PSCustomObject]@{Source='SQL1';Destination='SQL2';Database='DB2'}
>> ) | Measure-DbaDiskSpaceRequirement

Using a PSCustomObject with 2 databases to migrate on SQL2.

Example: 3
PS C:\> Import-Csv -Path .\migration.csv -Delimiter "`t" | Measure-DbaDiskSpaceRequirement | Format-Table -AutoSize

Using a CSV file. You will need to use this header line "SourceDestinationDatabaseDestinationDatabase".

Example: 4
PS C:\> $qry = "SELECT Source, Destination, Database FROM dbo.Migrations"
PS C:\> Invoke-DbaCmd -SqlInstance DBA -Database Migrations -Query $qry | Measure-DbaDiskSpaceRequirement

Using a SQL table. We are DBA after all!

Required Parameters

-Source

Source SQL Server.

Alias
Required True
Pipeline true (ByPropertyName)
Default Value
-Database

The database to copy. It MUST exist.

Alias
Required True
Pipeline true (ByPropertyName)
Default Value
-Destination

Destination SQL Server instance.

Alias
Required True
Pipeline true (ByPropertyName)
Default Value

Optional Parameters

-SourceSqlCredential

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 true (ByPropertyName)
Default Value
-DestinationDatabase

The database name at destination. May or may not be present, if unspecified it will default to the database name provided in SourceDatabase.

Alias
Required False
Pipeline true (ByPropertyName)
Default Value
-DestinationSqlCredential

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 true (ByPropertyName)
Default Value
-Credential

The credentials to use to connect via CIM/WMI/PowerShell remoting.

Alias
Required False
Pipeline true (ByPropertyName)
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