diskpart.exe can be used to display and configure file systempartitions. It is a command line program and thus can be used in cmd.exe.
When working with diskpart.exe, the available objects must first be listed (for example with list disk) and then an object must be selected (for example select disk …).
list disk
list disk shows the disks.
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 476 GB 14 MB *
Disk 1 Online 1947 MB 12 MB
list disk can be used to show if a harddisk uses a MBR (column Gpt contains no star), or a GPT partition (column Gpt contains a star).
Note: the Free column (which in the example above shows 14 MB) does not say how much space is free in the file system but rather how much space is not allocated for a file system.
C:\> dispkart
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 223 GB 0 B
Disk 1 Online 931 GB 0 B
DISKPART> select disk 1
Disk 1 is now the selected disk.
DISKPART> offline
Removing a drive letter
Apparently, a USB drive (that for example is mounted on D:) can be removed (ejected) with remove letter=d.
For a reason that I don't understand, a volume needs to be selected first:
DISKPART> sel vol 4
DISKPART> remove letter=d
Note: remove cannot be abbreviated with rem because rem indicates a comment (remark).
Scripts
diskpart can be invoked with the /s command to run scripts: