< Back
Get-DbaDiskSpace
Post
NAME Get-DbaDiskSpace
SYNOPSIS
Displays disk information for all local disk on a server.
SYNTAX
Get-DbaDiskSpace [[-ComputerName] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-Credential]
<Pscredential>] [[-Unit] <String>] [[-SqlCredential] <Pscredential>] [[-ExcludeDrive] <System.String[]>]
[-CheckFragmentation <Switch>] [-Force <Switch>] [-EnableException <Switch>] [<CommonParameters>]
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
PARAMETERS
-CheckFragmentation [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ComputerName [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target computer. Defaults to localhost.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Credential [<Pscredential>]
Credential object used to connect to the computer as a different user.
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
-ExcludeDrive [<System.String[]>]
Filter out drives - format is C:\\
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Force [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<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
-Unit [<String>]
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.
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
Author: Chrissy LeMaire (@cl), netnerds.net | Jakob Bindslet
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- 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.
RELATED LINKS
https://dbatools.io/Get-DbaDiskSpace
SYNOPSIS
Displays disk information for all local disk on a server.
SYNTAX
Get-DbaDiskSpace [[-ComputerName] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-Credential]
<Pscredential>] [[-Unit] <String>] [[-SqlCredential] <Pscredential>] [[-ExcludeDrive] <System.String[]>]
[-CheckFragmentation <Switch>] [-Force <Switch>] [-EnableException <Switch>] [<CommonParameters>]
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
PARAMETERS
-CheckFragmentation [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-ComputerName [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
The target computer. Defaults to localhost.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Credential [<Pscredential>]
Credential object used to connect to the computer as a different user.
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
-ExcludeDrive [<System.String[]>]
Filter out drives - format is C:\\
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Force [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<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
-Unit [<String>]
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.
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
Author: Chrissy LeMaire (@cl), netnerds.net | Jakob Bindslet
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- 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.
RELATED LINKS
https://dbatools.io/Get-DbaDiskSpace