How do I make new disks (make them online, initialize them, add new partition)?

This topic contains 1 reply, has 2 voices, and was last updated by  Dave Wyatt 2 years, 2 months ago.

  • Author
  • #38980


    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?

  • #38990

    Dave Wyatt

    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.

You must be logged in to reply to this topic.