list full partition information from powershell, just like from Disk Management
The following code snippet would list all properties of all volumes, each particular volume together with corresponding partition:
Get-Volume | ForEach-Object {
$VolObj = $_
$ParObj = Get-Partition | Where-Object { $_.AccessPaths -contains $VolObj.Path }
if ( $ParObj ) {
$VolObj | Select-Object -Property *
'------------'
$ParObj | Select-Object -Property *
'----------------------------------'
}
}
Try combining desired properties in a custom object or simply to standard output e.g. as
PS C:\Windows\system32> Get-Volume | ForEach-Object {
$VolObj = $_
$ParObj = Get-Partition | Where-Object { $_.AccessPaths -contains $VolObj.Path }
if ( $ParObj ) {
'{0,2} {1,2} {2,6} {3,20} {4,20} {5,2} {6}' -f $VolObj.DriveLetter,
$ParObj.DiskNumber,
$VolObj.FileSystem,
$VolObj.Size,
$VolObj.SizeRemaining,
$ParObj.PartitionNumber,
$VolObj.FileSystemLabel
}
}
D 0 NTFS 1000202039296 900793958400 1 DataDisk
1 NTFS 366997504 83173376 1 Rezervováno systémem
C 1 NTFS 119664537600 69979885568 2
Related videos on Youtube
JL Peyret
Interests/skills: PeopleSoft, SQL (Oracle, SQL Server, Postgresql), python, django.
Updated on September 18, 2022Comments
-
JL Peyret over 1 year
If I launch diskmgmt.msc, I end up full info on my partitions, including size and present file system (ntfs, fat32, etc...)
This has all the info I need to plan a Linux Mint multiboot. But I'd much rather have the info in text form, because I can't run the diskmanager while installing Linux.
Q: What can I use to list both what file system is being used, as well as size, for each partition?
diskpart list volume
looks like it would have done the trick, but not found in Windows 10.get-partition
gives me size, but w.o. telling me much else:DiskPath: \\?\scsi#disk&ven_&prod_liteonit_lcs-256#4&2bcd8382&0&040000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b} PartitionNumber DriveLetter Offset Size Type --------------- ----------- ------ ---- ---- 1 1048576 450 MB Recovery 2 472907776 100 MB System 3 577765376 16 MB Reserved 4 C 594542592 95.5 GB Basic 5 103135838208 450 MB Recovery 6 H 103607697408 107.32 GB Basic 7 I 218846199808 14.65 GB Basic 8 234574839808 20.01 GB Recovery DiskPath: \\?\scsi#disk&ven_&prod_st1000lm024_hn-m#4&2bcd8382&0&000000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b} PartitionNumber DriveLetter Offset Size Type --------------- ----------- ------ ---- ---- 1 D 1048576 465.75 GB Basic 2 E 500101545984 301.69 GB Basic 3 F 878569324544 15.62 GB Basic 4 G 895346540544 97.66 GB Basic DiskPath: \\?\usbstor#disk&ven_lexar&prod_usb_flash_drive&rev_1100#j8xx88thzzmnl0erdivy&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b} PartitionNumber DriveLetter Offset Size Type --------------- ----------- ------ ---- ---- 1 J 1048576 7.47 GB Basic
get-volume looks quite promising, except it doesn't me the size of the unformatted partitions:
DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining Size ----------- --------------- ---------- --------- ------------ ----------------- ------------- ---- I Fixed Healthy Unknown 0 B 0 B Restore NTFS Fixed Healthy OK 7.2 GB 20.01 GB Recovery NTFS Fixed Healthy OK 76.66 MB 450 MB K CD-ROM Healthy Unknown 0 B 0 B C NTFS Fixed Healthy OK 59.37 GB 95.5 GB J LINUX MINT FAT32 Removable Healthy OK 5.56 GB 7.45 GB NTFS Fixed Healthy OK 146.66 MB 450 MB H DATA NTFS Fixed Healthy OK 107.03 GB 107.32 GB E Data2 NTFS Fixed Healthy OK 142.64 GB 301.69 GB D Data1 NTFS Fixed Healthy OK 93.58 GB 465.75 GB F Fixed Healthy Unknown 0 B 0 B G Fixed Healthy Unknown 0 B 0 B
-
papo about 5 yearshezky, nice use of
-f
, if you don't like Format-Table with Calculated Property