Replace Diskpart with Windows PowerShell – Basic Storage cmdlets

Windows Server 8

Last week I made a blog post about how you can create a USB drive for Windows To Go. In my post I used diskpart.exe to format the USB drive. Now we don’t live in the stone age anymore, so I did the same with the new version of Windows PowerShell coming in Windows 8 and Windows Server 8.

Now here some basic cmdlets to do some simple storage operations, like clean a disk, create a partition and so on.

Lets start simple

List all disks

get-disk

Now get all partitions

get-partition

Now get all partitions of disk 0

get-partitiondisk

Clear a Disk

clear-disk

Create a new partition

new-partition

Format this volume

format-volume

Create new partition and format it with the label “USB”:

format-volume1

Change driveletter

set-partition

Set a partition active

set-partition1

Remove a partition

remove-partition

Bring a disk online

Remove Readonly flag

Initialize Disk with GPT

online disk

This is some basic knowledge about the storage module in PowerShell v3. Lets see how we can change the commands from using diskpart to Windows PowerShell.

Diskpart.exe

PowerShell:

replace-diskpart