Author Posts

May 12, 2016 at 1:56 am

Using the GUI in Windows server, I can add a new partition once new disks are physically added. Here is how the process goes without PowerShell:

1) physically add a new disk to the server
2) turn the server on and log in
3) Go to Server Manager -> Computer Management -> Storage -> Disk Management.
4) Right click "Disk 1" go to Online
5) Right click "Disk 1" go to Initialize Disk
6) Right click "Disk 1" go to New Simple partition ...
I create the disk to have it appear as the F drive utilizing all possible space.

I want to do steps 3 through 6 in PowerShell. How do I do this?

May 12, 2016 at 3:51 am

As long as you're using at least Server 2012, something like this should work:

Set-Disk -Number 1 -IsOffline $false -IsReadOnly $false
Initialize-Disk -Number 1 -PartitionStyle GPT
New-Partition -DiskNumber 1 -DriveLetter F -UseMaximumSize
Format-Volume -DriveLetter F -FileSystem NTFS

That particular example is hard-coded to use disk number 1; instead, you might want to do something with Get-Disk, and filter for disks that are currently offline.

For older operating systems, you'll probably wind up using diskpart.exe.