Format NTFS disk with allocation unit size of 64K via PowerShell

In a previous post I showed you how to get the allocation unit size of a Windows disk. In this post I will show you how to set it using PowerShell.

To set the allocation unit size in the GUI, follow the normal steps to format a drive and in the Format Partition box select 64K in the Allocation unit size drop-down per the below:

20160829170230

Provide a Volume Label if desired, then click Next and Finish, after which your drive will be formatted with NTFS with an allocation unit size of 64K.

To do this in PowerShell, run the script below:

$Disk = Get-Disk -Number 1
Set-Disk -InputObject $Disk -IsOffline $false
Initialize-Disk -InputObject $Disk
New-Partition $Disk.Number -UseMaximumSize -DriveLetter E
Format-Volume -DriveLetter E -FileSystem NTFS -AllocationUnitSize 65536 -NewFileSystemLabel DATAFILES -Confirm:$false

The script above will get Disk 1 in Disk Management and initialize it, bring it online, assign it letter E, format it with NTFS and an allocation unit size of 64K and assign it the label DATAFILES.

I found a great script here for performing the same task as above.

References:
Format-Volume
PowerShell Script to Configure SQL Server Storage