List all devices, partitions and volumes in Powershell

201,628

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
Share:
201,628
wishi
Author by

wishi

Updated on July 05, 2022

Comments

  • wishi
    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
    Bram over 7 years
    Get-Volume appears to be available only on Windows-Server 2012 and Windows-Server 2016.
  • Josh Desmond
    Josh Desmond about 7 years
    Get-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
    Chand almost 7 years
    is it possible to get Volume ## using powershell? (For windows 7)
  • Atif Ali
    Atif Ali over 5 years
    This also include the CD ROM which I am not sure is desired in all use cases keep that in mind guys.
  • Gustavo A Garcia
    Gustavo A Garcia over 4 years
    or you could also use Get-WmiObject Win32_LogicalDisk
  • Michael Shaw
    Michael Shaw over 4 years
    This is now the right answer. The answers using Get-PDDrive are for older versions of powershell
  • Lee_Dailey
    Lee_Dailey about 3 years
    this 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
    duct_tape_coder over 2 years
    This also does not include mount points such as iSCSI disks.
  • Rob
    Rob over 2 years
    If you want details, there is Get-Drive and Get-Partition, that can be piped for everything. Get-Drive | Get-Partition