As an automation process for disk configuration and manipulation, using the command line DiskPart is a must.
DiskPart allows us to manage disks, partitions or volumes just like Disk Management tool. To get started, type in 'cmd' after 'start + r' to open the command prompt, and type in 'DISKPART'.
In order to check the status of volumes, you can use the 'RESCAN' to kick start the process and it will bring you any changes to the disk.
To list all volumes on this device, use 'LIST VOLUME'.
Similarly, if we interested in disk or partition information, 'LIST DISK' and 'LIST PARTITION' are always available.
Now we can begin manipulating our objects. We use command:
SELECT [DISK|VOLUME|PARTITION] <ID> (i.e 'select disk 1')
to focus on a specific area. Once you committed to an object, the focus will not change until you specify otherwise. So it is always worth clarifying on which object you are currently working on to avoid some catastrophic events from happening. Yet there is a hierarchy you should also be aware of: once a volume is selected, the related disk and partition would also have the focus. Once a partition is selected, the related volume would also have the focus.
Despite the preparations, we can use the commands provided by DiskPart to do pretty much everything to manipulate our disks, volumes and partitions, including creating volumes, converting disks and etc. Since the operations are quite straight forward, what you need is to know how to get hold of them of anyone of interest, this can be done by using:
HELP <ACTIONNAME> or HELP
Just to life a little bit easier, we can use scripts to automate a set of operations to a one-click fashion, even remotely. The syntax is as following:
diskpart /s script.txt
(i.e. diskpart /s rescan.txt
diskpart /s listvolume.txt)
By putting one action name per script file (the script.txt file), and pile them up by sequence using the syntax above in a bat file (e.g. diskcheck.bat), a simple one-click script is done.
If necessary, a log file can also be provided to keep the output by using:
diskpart /s script.txt > logfile.txt
Hope this helps get rid of boring repeating job maintaining disks, and give you a bit of fun.