To use the command line to bring a disk online, create a partition, and format it, run the following commands:
C:\> Diskpart
DISKPART> list disk
DISKPART> select disk (id)
DISKPART> online disk (if the disk is not online)
DISKPART> attributes disk clear readonly
DISKPART> clean
DISKPART> convert mbr (or gpt)
DISKPART> create partition primary
DISKPART> select part 1
DISKPART> active (if this is the boot partition)
DISKPART> format fs=ntfs label=(name) quick
DISKPART> assign letter (letter)
DISKPART> list volume
The following are common errors you may see if you miss a step:
DISKPART> clean
DiskPart has encountered an error: The media is write protected.
See the System Event Log for more information.
Resolution: run attributes disk clear readonly before trying to clean the volume and create the partition.
DISKPART> convert mbr
Virtual Disk Service error:
The specified disk is not convertible. CDROMs and DVDs
are examples of disks that are not convertable.
Resolution: clear all data off the disk before converting by running the clean command.
DISKPART> create partition primary
Virtual Disk Service error:
There is not enough usable space for this operation.
Resolution: run clean before trying to create the partition.
DISKPART> format fs=ntfs quick
Virtual Disk Service error:
The volume is not online.
Resolution: online the disk, create the partition, and convert to mbr before formatting.