Setup New Disk on 2016 Server Core

When adding a disk to a server core machine, we don’t have the GUI and will need to use PowerShell to finish the disk setup.

To start, you’ll want to use Get-Disk to show your disks, you’ll want to note the disk number of the new disk you are setting up.  For this example, I’ll be working with disk 2.

snap2

Then you need to make sure the disk is online and set to read/write (by default it will be offline and read-only).

Get-Disk -Number 2 | Set-Disk –IsOffline:$false
Get-Disk -Number 2 | Set-Disk –IsReadOnly:$false

Then you need to initialize the disk, create a partition, and format it.  We can do all of this in one command.  Be careful that you’ve picked the right disk!

Get-Disk -Number 2 | Initialize-Disk –Passthru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -Confirm:$false –Force

Note that it automatically picks the first free drive letter.  In this case, it picked drive F.

snap3

If you want to use a different drive letter, you need to mix some PowerShell and WMI to make the change.  In my example I’m going to change drive F to be drive S.

$drive = Get-WMIObject –Class win32_volume –Filter "DriveLetter = 'f:'"
Set-WMIInstance –input $drive –arguments @{DriveLetter="s:"}

Once you’re all done, you can use Get-Volume to make sure everything is set the way you want.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s