commands

^

Get-DbaDiskSpace

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

 

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

Synopsis

Displays disk information for all local disk on a server.

Description

Returns a custom object with server name, name of disk, label of disk, total size, free size, percent free, block size and filesystem.

By default, this function only shows drives of types 2 and 3 (removable disk and local disk).

Requires Windows administrator access on SQL Servers

Syntax

Get-DbaDiskSpace
    [[-ComputerName] <DbaInstanceParameter[]>]
    [[-Credential] <PSCredential>]
    [[-Unit] <String>]
    [[-SqlCredential] <PSCredential>]
    [[-ExcludeDrive] <String[]>]
    [-CheckFragmentation]
    [-Force]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaDiskSpace -ComputerName srv0042

Get disk space for the server srv0042.

Example: 2
PS C:\> Get-DbaDiskSpace -ComputerName srv0042 -Unit MB

Get disk space for the server srv0042 and displays in megabytes (MB).

Example: 3
PS C:\> Get-DbaDiskSpace -ComputerName srv0042, srv0007 -Unit TB

Get disk space from two servers and displays in terabytes (TB).

Example: 4
PS C:\> Get-DbaDiskSpace -ComputerName srv0042 -Force

Get all disk and volume space information.

Example: 5
PS C:\> Get-DbaDiskSpace -ComputerName srv0042 -ExcludeDrive 'C:\'

Get all disk and volume space information.

Optional Parameters

-ComputerName

The target computer. Defaults to localhost.

Alias
Required False
Pipeline true (ByValue)
Default Value $env:COMPUTERNAME
-Credential

Credential object used to connect to the computer as a different user.

Alias
Required False
Pipeline false
Default Value
-Unit

This parameter has been deprecated and will be removed in 1.0.0
All properties previously generated through this command are present at the same time, but hidden by default.

Alias
Required False
Pipeline false
Default Value GB
Accepted Values Bytes,KB,MB,GB,TB,PB
-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
-ExcludeDrive

Filter out drives - format is C:<br>

Alias
Required False
Pipeline false
Default Value
-CheckFragmentation

If this switch is enabled, fragmentation of all file systems will be checked.
This will increase the runtime of the function by seconds or even minutes per volume.

Alias
Required False
Pipeline false
Default Value False
-Force

Enabling this switch will cause the command to include ALL drives.
By default, only local disks and removable disks are shown, and hidden volumes are excluded.

Alias
Required False
Pipeline false
Default Value False
-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