< Back

Measure-DbaDiskSpaceRequirement

Mon Jan 13, 2020 12:33 pm

NAME Measure-DbaDiskSpaceRequirement



SYNOPSIS

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





SYNTAX

Measure-DbaDiskSpaceRequirement [-Source] <DbaInstanceParameter> [-Database] <String> [[-SourceSqlCredential]

<Pscredential>] [-Destination] <DbaInstanceParameter> [[-DestinationDatabase] <String>]

[[-DestinationSqlCredential] <Pscredential>] [[-Credential] <Pscredential>] [-EnableException <Switch>]

[<CommonParameters>]





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.





PARAMETERS

-Credential [<Pscredential>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Database [<String>]

The database to copy. It MUST exist.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Destination [<DbaInstanceParameter>]

Destination SQL Server instance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DestinationDatabase [<String>]

The database name at destination.

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-DestinationSqlCredential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Source [<DbaInstanceParameter>]

Source SQL Server.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SourceSqlCredential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Server, Management, Space, Database

Author: Pollus Brodeur (@pollusb)



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



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

"Source<tab>Destination<tab>Database<tab>DestinationDatabase".

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



RELATED LINKS

https://dbatools.io/Measure-DbaDiskSpaceRequirement