Tuesday, July 16, 2013

Format a drive from PowerShell

After adding a new drive to a Windows Server 2012 Core machine, you will need to format it and assign a drive letter. This is how to do it.

$disk = Get-Disk | ? PartitionStyle -eq Raw
$disk | Initialize-Disk
$part = New-Partition -DiskNumber $disk.Number -UseMaximumSize
Initialize-Volume -Partition $part -FileSystem ReFS
Add-PartitionAccessPath -DiskNumber $disk.Number -PartitionNumber $part.PartitionNumber -AccessPath D:\

0 comments:

Post a Comment