Monthly Archive


Testing the 4K boundary

Advanced Format disks have started shipping –see

These disks use a 4096 byte sector instead of 512. To get the best performance from these disks the partitions have to be aligned to a 4K boundary. This happens automatically in Windows 2008 and above. 

We need to be able to start testing partition alignment. This function uses a couple of WMI classes to do just that.

function test-4KAligned {
param (

$partitions = Get-WmiObject -Class Win32_DiskPartition -ComputerName $computer

foreach ($partition in $partitions){
  $query = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} WHERE AssocClass=Win32_LogicalDiskToPartition"
  $disktopart = Get-WmiObject -ComputerName $computer -Query $query
if (($partion.StartingOffset % 4096) -eq 0){
   $align = $true
else {
   $align = $false
$diskpartition = New-Object -TypeName PSObject -Property @{
   Partition = $partition.Name
   Description = $partition.Description
   AlignedTo4Kboundary = $align
   Drive = $disktopart.DeviceID
if ($drive) {
   if ($drive -eq $diskpartition.Drive){$diskpartition}
else {$diskpartition}


Tests disk partition alignment to 4k boundary

Tests disk partition alignment to 4k boundary.

Default is that all drives are tested

.PARAMETER  computer
Computer to test

Drive to test


Tests local machine

test-4kaligned -computer server01

Tests remote machine

test-4kaligned -computer server01 -drive C:

Tests C: drive on remote machine



The test is performed using modulus arithmetic on the starting offset. A result of zero means its divisible exactly by 4096 so is aligned.

Leave a Reply