PowerShell Genie

Get-PSDrive

Use Get-PSDrive to list the drives available in the session, including those that are not filesystems.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Get-PSDrive

Syntax

1PS> Get-PSDrive [[-Name] <string[]>] [-PSProvider <String[]>] [-Scope <String>] [<CommonParameters>]
See the command anatomy

Inspect this authored example with fictional data in the bounded browser model. The numbered stages show how its objects change.

Get-PSDrive | Select-Object Name, Provider, Root
  1. Stage 1Get-PSDrivePositional values or no named parameters
  2. Stage 2Select-ObjectPositional values or no named parameters

    Try it

    Windows PowerShell

    Browser simulation · fictional data; no changes to your computer.

    Interactive simulation · fictional data

    Examples

    Select Name, Provider, Root

    1PS> Get-PSDrive | Select-Object Name, Provider, Root
    Show reference output

    Illustrative output · values vary by environment

    Name      Provider     Root              
    --------  -----------  ------------------
    C         FileSystem   C:\               
    D         FileSystem   D:\               
    HKCU      Registry     HKEY_CURRENT_USER 
    HKLM      Registry     HKEY_LOCAL_MACHINE
    Env       Environment                    
    Function  Function                       
    Variable  Variable                       
    Alias     Alias                          

    Get-PSDrive -PSProvider FileSystem

    1PS> Get-PSDrive -PSProvider FileSystem | Select-Object Name, Used, Free
    Show reference output

    Illustrative output · values vary by environment

    Name  Used         Free
    ----  ----         ----
    C     313317867520 197890842624
    D     342523641856 657881497600

    Get-PSDrive -Name C

    1PS> Get-PSDrive -Name C
    Show reference output

    Illustrative output · values vary by environment

    Name Used (GB) Free (GB) Provider   Root
    ---- --------- --------- --------   ----
    C       291.8     184.3 FileSystem C:\

    Parameters

    Parameter definitions:

    • -Name
    • -PSProvider
    • -Scope

    Get-PSDrive on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Get-PSDrive when you need to list the drives available in the session, including those that are not filesystems. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: A drive missing in another process may have been created only in the original session. Inspect provider and scope and do not assume a session-only drive is available to a scheduled task. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Get-Location. Get-PSDrive lists drives exposed by PowerShell providers; Get-Location identifies the current provider location. A PSDrive is not necessarily a physical disk or a persistent Windows mapping. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Get-PSDrive reference on Microsoft Learn

    Recap

    Get-PSDrive Use Get-PSDrive to list the drives available in the session, including those that are not filesystems.

    Next: Get-PSSession
    Genie guideGet-PSDrive

    Use Get-PSDrive to list the drives available in the session, including those that are not filesystems. The console below is pre-loaded — run it, then change a value and run it again.