How to write scripts for disk management with diskpart
Disk management in Windows is possible from the command line, especially with tools such as diskpart. Diskpart can be scripted for quicker disk management.
Access to the Windows command line and a file editor.
Open a file editor and enter diskpart commands such as:
select disk 1
The above will simply offline the second disk recognized by diskpart. This disk can be onlined at another time.
Next, you can save this file with a .txt file extension. With the command line open, you can run this script by typing:
diskpart /s C:\Users\User\Folder\filename.txt
and the disk will then be offlined.
For a list of diskpart commands, type:
within a diskpart session.