List all devices, partitions and volumes in Powershell
Solution 1
To get all of the file system drives, you can use the following command:
gdr -PSProvider 'FileSystem'
gdr
is an alias for Get-PSDrive
, which includes all of the "virtual drives" for the registry, etc.
Solution 2
Get-Volume
You will get: DriveLetter, FileSystemLabel, FileSystem, DriveType, HealthStatus, SizeRemaining and Size.
Solution 3
Firstly, on Unix you use mount
, not ls /mnt
: many things are not mounted in /mnt
.
Anyhow, there's the mountvol
DOS command, which continues to work in Powershell, and there's the Powershell-specific Get-PSDrive
.
Solution 4
Run command:
Get-PsDrive -PsProvider FileSystem
For more info see:
Solution 5
Though this isn't 'powershell' specific... you can easily list the drives and partitions using diskpart, list volume
PS C:\Dev> diskpart
Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: Box
DISKPART> list volume
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D DVD-ROM 0 B No Media
Volume 1 C = System NTFS Partition 100 MB Healthy System
Volume 2 G C = Box NTFS Partition 244 GB Healthy Boot
Volume 3 H D = Data NTFS Partition 687 GB Healthy
Volume 4 E System Rese NTFS Partition 100 MB Healthy
wishi
Updated on July 05, 2022Comments
-
wishi almost 2 years
I have multiple volumes (as nearly everybody nowadays): on Windows they end up specified as C:, D: and so on. How do I list these all like on a Unix machine with "ls /mnt/" with Powershell?
-
Bram over 7 yearsGet-Volume appears to be available only on Windows-Server 2012 and Windows-Server 2016.
-
Josh Desmond about 7 yearsGet-Volume worked for me running powershell 5.1. Perhaps they made this standard in recent years/recent updates. This answer should get more attention.
-
Chand almost 7 yearsis it possible to get Volume ## using powershell? (For windows 7)
-
Atif Ali over 5 yearsThis also include the CD ROM which I am not sure is desired in all use cases keep that in mind guys.
-
Gustavo A Garcia over 4 yearsor you could also use Get-WmiObject Win32_LogicalDisk
-
Michael Shaw over 4 yearsThis is now the right answer. The answers using Get-PDDrive are for older versions of powershell
-
Lee_Dailey about 3 yearsthis seems like a VERY minor variation of one of the previous Answers. what is the benefit to yours that is not in the other?
-
duct_tape_coder over 2 yearsThis also does not include mount points such as iSCSI disks.
-
Rob over 2 yearsIf you want details, there is Get-Drive and Get-Partition, that can be piped for everything. Get-Drive | Get-Partition