To effectively work with Diskpart on a Server Core, it is necessary to write some small batch script's, because you can't execute diskpart in a remote powershell session.
To get startet, place the Diskpart batch script's into a share on your local computer and mount it to your server core:
Limited access to the Server Core:
or
Full access to the Server Core:
Copy the files to the Servercore \\servercore\C$ share, using an administrative user.
How to use Diskpart and your scripts:
I allways have a basic "list" script to get an overview over the current situation:
And it's executed like this:
You can give any/no filetype to the script (list.txt, list.cmd) you like.
Output example:
What's most important to find out is, if a dvd drive is mounted on the server core, cause this will change the volume numbers and you have to use a different script. Copy the examples to a file and execute them with DISKPART /S:
Warning! If a volume 2,3,or 4 is already existing on your server and its not the system volume it will be deleted! Try in a test evironment first please!
Example 1 (DVD = Volume 1):
This will set Disk 2 online, create a new Volume (3) on Disk 2, do a standard format of volume 3 and add the next free drive letter to it.
Example 2 (no DVD):
This will set Disk 2 online, create a new Volume (2) on Disk 2, do a Standard format of volume 2 and add the next free drive letter to it.
Example 3 (add second volume after Example 1):
This will set Disk 3 online, create a new Volume (4) on Disk 3, do a Standard format of volume 4 and add the next free drive letter to it.
I recommend you to work with DISKPART only! Powershell command's like get-psdrive won't rescan for new drive's and partitions you have added to the server! They will update only after a logging of your remote session and reconnecting to the Server core. To update the drives in Diskpart just execute the list script again and the RESCAN command will scan your server for new drives (yes, it's not really necessary , but it won't hurt).
Sometimes one or two of the last commands of the script's have not executed at all and I had to add a short script that will only execute the ASSIGN command for example. Maybe it's better to execute DISKPART on a large drives/volumes in a PowerShell backround job to avoid the permanent updating of your remoteshell when the format command ist executed.
I hope this was informative and good luck!