Command performs the full setup of a new RAW disk in one PowerShell pipeline:

explain: Get-Disk | Where PartitionStyle -eq “RAW” | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel “MYDATA”

This command performs the full setup of a new RAW disk in one PowerShell pipeline:

Get-Disk |
Where PartitionStyle -eq "RAW" |
Initialize-Disk -PartitionStyle GPT -PassThru |
New-Partition -UseMaximumSize -AssignDriveLetter |
Format-Volume -FileSystem NTFS -NewFileSystemLabel "MYDATA"

Full meaning

Find any uninitialized disk, initialize it as GPT, create one large partition, assign a drive letter, and format it as NTFS with the label MYDATA.


Step-by-step explanation

1. Find disks

Get-Disk

Lists all disks connected to the system.


2. Select only RAW disks

Where PartitionStyle -eq "RAW"

Filters only disks whose partition style is RAW.

RAW means:

The disk is new or uninitialized.

3. Initialize the disk as GPT

Initialize-Disk -PartitionStyle GPT -PassThru

This prepares the disk for use.

GPT means GUID Partition Table, the modern partition style.

-PassThru is important here because it sends the initialized disk object to the next command in the pipeline.

Without -PassThru, the next command may not receive the disk object.


4. Create a partition

New-Partition -UseMaximumSize -AssignDriveLetter

Creates one partition using all available disk space.

-UseMaximumSize means:

Use the full disk space.

-AssignDriveLetter means:

Automatically assign a drive letter, such as E: or F:

5. Format the volume

Format-Volume -FileSystem NTFS -NewFileSystemLabel "MYDATA"

Formats the new partition.

NTFS is the Windows file system.

MYDATA is the volume label/name that appears in File Explorer.


What happens after running it?

A new usable drive appears, for example:

E:  MYDATA

You can then store files on it.


Very important warning

This command can erase or prepare disks. Use it only on a new test disk, preferably inside a VM.

Before running it, always check:

Get-Disk

Safer version:

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

Then confirm the correct disk before initializing.


Student comment

# This command finds uninitialized RAW disks, initializes them using GPT,
# creates one full-size partition, assigns a drive letter,
# and formats the volume as NTFS with the label MYDATA.

REF: AI Tools/ChatGPT

Leave a Reply