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.
Displays disk information for all local disk on a server.
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
Get-DbaDiskSpace
[[-ComputerName] <DbaInstanceParameter[]>]
[[-Credential] <PSCredential>]
[[-Unit] <String>]
[[-SqlCredential] <PSCredential>]
[[-ExcludeDrive] <String[]>]
[-CheckFragmentation]
[-Force]
[-EnableException]
[<CommonParameters>]
PS C:\> Get-DbaDiskSpace -ComputerName srv0042
Get disk space for the server srv0042.
PS C:\> Get-DbaDiskSpace -ComputerName srv0042 -Unit MB
Get disk space for the server srv0042 and displays in megabytes (MB).
PS C:\> Get-DbaDiskSpace -ComputerName srv0042, srv0007 -Unit TB
Get disk space from two servers and displays in terabytes (TB).
PS C:\> Get-DbaDiskSpace -ComputerName srv0042 -Force
Get all disk and volume space information.
PS C:\> Get-DbaDiskSpace -ComputerName srv0042 -ExcludeDrive 'C:\'
Get all disk and volume space information.
The target computer. Defaults to localhost.
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value | $env:COMPUTERNAME |
Credential object used to connect to the computer as a different user.
Alias | |
Required | False |
Pipeline | false |
Default Value |
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 |
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 |
Filter out drives - format is C:<br>
Alias | |
Required | False |
Pipeline | false |
Default Value |
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 |
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 |
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 |