I am trying to use Command or PowerShell to know where on a disk unallocated space is available.
For example below the unallocated space is present after G: drive (or Partition 1).
Using the command echo list disk | diskpart I can only know the Unallocated space.
Is there any way to know this information?

gwmi Win32_DiskPartitionand detect the gaps by comparing StartingOffset property with an accumulated value of Size properties.