Powershell

How to Use the Get-PSDrive (Microsoft.PowerShell.Management) Cmdlet in PowerShell?

Powershell uses the “Get-PSDrive” cmdlet to obtain a list of drives in the currently active session. It can get all or a particular drive in PowerShell. The standard alias for the “Get-PSDrive” cmdlet is “gdr”. The “Get-PSDrive” cmdlet gets Windows logical drives, drives exposed by PowerShell providers, and drives created with “New-PSDrive” cmdlet.

This article will elaborate on the use of the PowerShell “Get-PSDrive” cmdlet.

How Do I Use PowerShell’s Get-PSDrive Cmdlet?

As we described above, the “Get-PSDrive” cmdlet is responsible for retrieving the list of drives in the current session. Simply invoke the “Get-PSDrive” cmdlet in PowerShell to accomplish this.

Syntax

The syntax of the “Get-PSDrive” cmdlet is stated below:

Get-PSDrive [-Name] [-Scope] [-PSProvider] [CommonParameters]

Example 1: Use the “Get-PSDrive” Cmdlet to Retrieve the Drives in the Currently Active Session

Execute the following command to retrieve the drives in the active current session:

Get-PSDrive

Example 2: Use the “Get-PSDrive” Cmdlet to Get a Specified Drive on the Computer

To get a particular drive on a computer, first, use the “Get-PSDrive” cmdlet and then assign it the drive letter:

Get-PSDrive C

Example 3: Use the “Get-PSDrive” Cmdlet to Retrieves Drives Supported by the File System Provider

First, use the “Get-PSDrive” cmdlet with the “-PSProvider” option, and then use the “FileSystem” value to get the discs that are supported by the Windows “File System Provider”:

Get-PSDrive -PSProvider FileSystem

That’s it! You have learned the usage of PowerShell’s “Get-PSDrive” cmdlet.

Conclusion

The “Get-PSDrive” cmdlet in PowerShell gets one or a list of drives in the current session. It can get the “Windows logical drives”, “Certificate”, “Function”, “Alias”, “HKLM”, “HKCU” drives. This article has elaborated on the usage of the “Get-PSDrive” cmdlet with the help of various examples.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.