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:
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:
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:
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”:
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.