commands

^

Test-DbaDiskSpeed

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

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

Synopsis

Obtains I/O statistics based on the DMV sys.dm_io_virtual_file_stats

Description

Obtains I/O statistics based on the DMV sys.dm_io_virtual_file_stats:

https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-io-virtual-file-stats-transact-sql

This command uses a query from Rich Benner
https://github.com/RichBenner/PersonalCode/blob/master/Disk_Speed_Check.sql

...and also based on further adaptations referenced at https://github.com/dataplat/dbatools/issues/6551#issue-623216718

Syntax

Test-DbaDiskSpeed
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Database] <Object[]>]
    [[-ExcludeDatabase] <Object[]>]
    [[-AggregateBy] <String>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Test-DbaDiskSpeed -SqlInstance sql2008, sqlserver2012

Tests how disks are performing on sql2008 and sqlserver2012.

Example: 2
PS C:\> Test-DbaDiskSpeed -SqlInstance sql2008 -Database tempdb

Tests how disks storing tempdb files on sql2008 are performing.

Example: 3
PS C:\> Test-DbaDiskSpeed -SqlInstance sql2008 -AggregateBy "File" -Database tempdb

Returns the statistics aggregated to the file level. This is the default aggregation level if the -AggregateBy param is omitted. The -Database or -ExcludeDatabase params can be used to filter for
specific databases.

Example: 4
PS C:\> Test-DbaDiskSpeed -SqlInstance sql2008 -AggregateBy "Database"

Returns the statistics aggregated to the database/disk level. The -Database or -ExcludeDatabase params can be used to filter for specific databases.

Example: 5
PS C:\> Test-DbaDiskSpeed -SqlInstance sql2008 -AggregateBy "Disk"

Returns the statistics aggregated to the disk level. The -Database or -ExcludeDatabase params can be used to filter for specific databases.

Example: 6
PS C:\> $results = @(instance1, instance2) | Test-DbaDiskSpeed

Returns the statistics for instance1 and instance2 as part of a pipeline command

Example: 7
PS C:\> $databases = @('master', 'model')

$results = Test-DbaDiskSpeed -SqlInstance sql2019 -Database $databases
Returns the statistics for more than one database specified.

Example: 8
PS C:\> $excludedDatabases = @('master', 'model')

$results = Test-DbaDiskSpeed -SqlInstance sql2019 -ExcludeDatabase $excludedDatabases
Returns the statistics for databases other than the exclusions specified.

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

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

The database(s) to exclude - this list is auto-populated from the server

Alias
Required False
Pipeline false
Default Value
-AggregateBy

Specify the level of aggregation for the statistics. The available options are 'File' (the default), 'Database', and 'Disk'.

Alias
Required False
Pipeline false
Default Value File
Accepted Values Database,Disk,File
-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