You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: public/Get-DbaDiskSpace.ps1
+30-17Lines changed: 30 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ function Get-DbaDiskSpace {
4
4
Retrieves disk space and filesystem details from SQL Server host systems for capacity monitoring and performance analysis.
5
5
6
6
.DESCRIPTION
7
-
Queries Windows disk volumes on SQL Server systems using WMI to gather critical storage information for database administration. Returns comprehensive disk details including capacity, free space, filesystem type, and optional fragmentation analysis.
7
+
Queries Windows disk volumes on SQL Server systems using WMI to gather critical storage information for database administration. Returns comprehensive disk details including capacity, free spaceand filesystem type.
8
8
9
9
Essential for SQL Server capacity planning, this function helps DBAs monitor disk space before growth limits impact database operations. Use it to verify adequate space for backup operations, identify performance bottlenecks from fragmented volumes hosting data or log files, and maintain compliance documentation for storage utilization.
10
10
@@ -20,23 +20,16 @@ function Get-DbaDiskSpace {
20
20
Credential object used to connect to the computer as a different user.
21
21
22
22
.PARAMETERUnit
23
-
This parameter has been deprecated and will be removed in 1.0.0.
24
-
All size properties (Bytes, KB, MB, GB, TB, PB) are now available simultaneously in the output object but hidden by default for cleaner display.
25
-
26
-
.PARAMETERSqlCredential
27
-
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
28
-
29
-
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
30
-
31
-
For MFA support, please use Connect-DbaInstance.
23
+
Displays the Capacity and Free values in the specified unit: Bytes, KB, MB, GB or TB.
24
+
By default each value picks a human friendly unit for display ("1.82 TB"). The underlying values are not changed, and every unit stays available through the SizeIn* and FreeIn* properties of the output object.
32
25
33
26
.PARAMETERExcludeDrive
34
27
Specifies drive letters to exclude from the disk space report, using the format 'C:\' or 'D:\'.
35
28
Use this to skip system drives or non-SQL storage when focusing on database file locations, or to exclude network drives that may cause timeouts.
36
29
37
30
.PARAMETERCheckFragmentation
38
-
Enables filesystem fragmentation analysis for all volumes, which can impact SQL Server I/O performance when database or log files are stored on fragmented drives.
39
-
This significantly increases runtime (seconds to minutes per volume) but provides critical data for troubleshooting slow database operations or planning defragmentation maintenance.
31
+
This parameter is deprecated and will cause the command to stop with a warning.
32
+
The fragmentation analysis was removed from this command because the underlying DefragAnalysis call took minutes per volume.
40
33
41
34
.PARAMETERForce
42
35
Includes all drive types and hidden volumes in the results, not just local and removable disks (DriveType 2 and 3).
@@ -70,8 +63,8 @@ function Get-DbaDiskSpace {
70
63
- ComputerName: The name of the computer
71
64
- Name: The volume name (drive letter or UNC path, e.g., 'C:\' or '\\server\share')
72
65
- Label: The volume label/name if assigned
73
-
- Capacity: Total disk capacityin the specified unit (default GB)
74
-
- Free: Free space availablein the specified unit (default GB)
66
+
- Capacity: Total disk capacity, displayed in a human friendly unit or in the unit requested with -Unit
67
+
- Free: Free space available, displayed in a human friendly unit or in the unit requested with -Unit
75
68
- PercentFree: Percentage of disk space that is free
Stop-Function-Message "The parameter CheckFragmentation is deprecated. The fragmentation analysis has been removed from this command because the underlying DefragAnalysis call took minutes per volume."
132
+
return
133
+
}
138
134
139
135
$condition=" WHERE DriveType = 2 OR DriveType = 3"
140
136
if (Test-Bound'Force') {
141
137
$condition=""
142
138
}
143
139
140
+
# The Capacity and Free properties are Size objects that pick a human friendly display unit.
141
+
# A requested unit overrides that display without changing the underlying values.
0 commit comments