Execution Flow
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
| Parameter | Type | Default | Description |
|---|---|---|---|
| -Drive | String[] | — | Single letter drive identifiers (e.g. "D", "E"). Pipeline-capable. ByDrive parameter set. |
| -SqlInstance | String | — | SQL Server instance. Auto-discovers data/log/tempdb/backup paths. BySqlInstance parameter set. |
| -SqlCredential | PSCredential | — | Credential for the SQL connection (BySqlInstance only). |
| -RecommendedBlockSize | Int | Get-sqmConfig 'CheckDiskBlockSize' (65536) | Expected block size in bytes. Overrides the config value when provided. |
Return Value
| Property | Description |
|---|---|
| Drive | Drive letter (e.g. "D"). |
| Path | Full path checked (e.g. "D:\"). |
| Label | Volume label from Win32_Volume. |
| BlockSize | Actual NTFS allocation unit size in bytes. |
| BlockSizeKB | Actual block size in KB. |
| RecommendedBlockSize | Expected block size in bytes. |
| IsRecommended | Boolean — true if BlockSize equals RecommendedBlockSize. |
| Status | OK / Warning (wrong block size) / NotNTFS / Error. |
| SqlPath | SQL path that caused this drive to be included (BySqlInstance mode only). |
| SqlRole | Data / 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