Get-sqmDiskBlockSize Configuration

Checks the NTFS allocation unit size (block size) of one or more drives via WMI Win32_Volume. Compares against a configurable recommended block size (default 64 KB). Supports two modes: explicit drive letter(s) or automatic detection of all SQL Server data/log/TempDB paths from the registry and SMO.

Execution Flow

START Read CheckDiskBlockSize from Get-sqmConfig (default 65536) Parameter set? ByDrive foreach $Drive in $Drive[] [pipeline] Validate single letter A-Z Get-CimInstance Win32_Volume WHERE Name="X:\\" Check FileSystem = "NTFS" BlockSize = $vol.BlockSize Status: OK / Warning / NotNTFS / Error IsRecommended: BlockSize -eq RecommendedBlockSize Build result object per drive Catch: Status=Error, add to $results BySqlInstance BySqlInstance Registry: SQL instance names BackupDirectory/DefaultData/DefaultLog SMO: TempDB file paths Extract unique drive letters → same WMI check per drive Tag: SqlPath, SqlRole (Data/Log/Tempdb) Return $results[] DONE

Synopsis

Reads the NTFS allocation unit size (block size) via Get-CimInstance Win32_Volume and compares it against the recommended value (default 65536 bytes = 64 KB) read from Get-sqmConfig -Key 'CheckDiskBlockSize'. In -BySqlInstance mode, the function auto-discovers all relevant drives from registry paths and SMO TempDB file locations rather than requiring explicit drive letter input.

No dbatools required for ByDrive mode. BySqlInstance mode uses SMO (SQL Management Objects) to read TempDB paths and requires local WMI access.

Syntax

# Mode 1: explicit drive letters
Get-sqmDiskBlockSize
    -Drive <String[]>            # pipeline, single letter A-Z
    [-RecommendedBlockSize <Int>] # overrides config value

# Mode 2: auto-detect from SQL instance
Get-sqmDiskBlockSize
    -SqlInstance <String>
    [-SqlCredential <PSCredential>]
    [-RecommendedBlockSize <Int>]

Parameters

ParameterTypeDefaultDescription
-DriveString[]Single letter drive identifiers (e.g. "D", "E"). Pipeline-capable. ByDrive parameter set.
-SqlInstanceStringSQL Server instance. Auto-discovers data/log/tempdb/backup paths. BySqlInstance parameter set.
-SqlCredentialPSCredentialCredential for the SQL connection (BySqlInstance only).
-RecommendedBlockSizeIntGet-sqmConfig 'CheckDiskBlockSize' (65536)Expected block size in bytes. Overrides the config value when provided.

Return Value

PropertyDescription
DriveDrive letter (e.g. "D").
PathFull path checked (e.g. "D:\").
LabelVolume label from Win32_Volume.
BlockSizeActual NTFS allocation unit size in bytes.
BlockSizeKBActual block size in KB.
RecommendedBlockSizeExpected block size in bytes.
IsRecommendedBoolean — true if BlockSize equals RecommendedBlockSize.
StatusOK / Warning (wrong block size) / NotNTFS / Error.
SqlPathSQL path that caused this drive to be included (BySqlInstance mode only).
SqlRoleData / Log / Tempdb / Backup (BySqlInstance mode only).

Examples

# Check specific drives
Get-sqmDiskBlockSize -Drive "D","E","F"

# Auto-detect from SQL instance (reads registry + SMO)
Get-sqmDiskBlockSize -SqlInstance "SQL01"

# Show only non-recommended drives
Get-sqmDiskBlockSize -SqlInstance "SQL01" | Where-Object { -not $_.IsRecommended }

# Override with custom block size (4 KB file server drives)
"G","H" | Get-sqmDiskBlockSize -RecommendedBlockSize 4096