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 Profile photo of Dave Wyatt Dave Wyatt 4 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38980
    Profile photo of Kiran
    Kiran
    Participant

    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
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.