How to Use Windows PowerShell ‘Get-Disk’ and ‘Initialize-Disk’ for Storage Provisioning

The End of Disk Management

When you attach a brand new, raw hard drive or SAN LUN to a Windows Server, it is entirely unusable. Before Windows can store data on it, the drive must be Initialized (given a partition table like GPT), Partitioned (carved into logical blocks), and Formatted (given a file system like NTFS).

Historically, administrators achieved this by opening the graphical diskmgmt.msc (Disk Management) utility and right-clicking the black “Unallocated” space.

However, if you are provisioning a massive database server with 24 separate SSDs, clicking through graphical wizards 24 times is agonizing and prone to human error. To automate massive storage provisioning, modern administrators use the PowerShell Storage module, specifically Get-Disk and Initialize-Disk.

1. Auditing Attached Storage (Get-Disk)

Before you modify anything, you must identify the exact disk number of the raw drive.

Get-Disk

This command outputs a clean table of every physical drive attached to the server. You are specifically looking for drives where the PartitionStyle is listed as RAW or the OperationalStatus is Offline.

To filter the list and only show brand-new, unconfigured drives:

Get-Disk | Where-Object PartitionStyle -eq "RAW"

2. The Complete Provisioning Pipeline

PowerShell is designed for pipelines. You can take a raw disk, initialize it, partition it, format it, and assign a drive letter in a single, unbroken chain of commands.

Suppose Get-Disk revealed that the new 2TB SSD is “Disk 2”.

Get-Disk -Number 2 | 
    Initialize-Disk -PartitionStyle GPT -PassThru | 
    New-Partition -UseMaximumSize -AssignDriveLetter | 
    Format-Volume -FileSystem NTFS -NewFileSystemLabel "DatabaseData" -Confirm:$false

Breaking down the pipeline:

  1. Get-Disk: Grabs the specific raw disk object.
  2. Initialize-Disk: Stamps the drive with a modern GUID Partition Table (GPT), which is required for drives larger than 2TB. The -PassThru flag forces the command to pass the disk object down the pipeline to the next command (otherwise the chain stops).
  3. New-Partition: Carves the initialized disk. We tell it to use 100% of the available space, and automatically assign the next available drive letter (e.g., “D:”).
  4. Format-Volume: Physically formats the raw partition into the NTFS file system, names the drive “DatabaseData”, and suppresses the “Are you sure?” confirmation prompt so the script runs silently.

This massive, multi-step graphical process is executed in roughly 3 seconds.

3. Bulk Provisioning (The Enterprise Scale)

The true power of this pipeline is apparent when you scale it. If you just plugged 10 new raw hard drives into a storage server, you don’t even need to know their disk numbers. You can format all of them simultaneously.

Get-Disk | Where-Object PartitionStyle -eq "RAW" | 
    Initialize-Disk -PartitionStyle GPT -PassThru | 
    New-Partition -UseMaximumSize -AssignDriveLetter | 
    Format-Volume -FileSystem NTFS -Confirm:$false

This single command grabs every single unconfigured drive in the entire chassis and instantly brings them all online, formatted, and ready for data.

Conclusion

The PowerShell Storage module entirely obsoletes the graphical Disk Management interface. By leveraging Get-Disk and pipelining into Initialize-Disk, infrastructure engineers can provision massive SAN deployments and local RAID arrays with surgical precision and absolute repeatability.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.