Powershell & Disk Setup

So recently I had to setup some drives but wanted to bypass the traditonal compmgmt route (or diskmgmt).  Powershell proved to be much faster than the old way, it only takes a few seconds to setup an SSD (longer if you want to format).


#which drives are partition style raw?

Get-Disk

# so in the above example I noted disk number 4 is RAW, I wanted it to be the N drive
# allocate all space, format as GPT and label it "N-DRIVE"

Get-Disk | Where-object Number -eq 4 | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -DriveLetter N -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "N-DRIVE" -Confirm:$false

#

 

References:
https://devblogs.microsoft.com/scripting/use-powershell-to-initialize-raw-disks-and-to-partition-and-format-volumes/

Want to Reply?

This site uses Akismet to reduce spam. Learn how your comment data is processed.

OR

LOGIN OR REGISTER

Registered users with one approved comment can comment without moderation