Working With PowerShell Drives

Windows PowerShell drives are data store locations that you can access like any other file system drives in Windows PowerShell. The Windows PS providers create some drives for you, such as the file system drives (including C: and D:). Below examples show how to work with PowerShell Drives in Windows PowerShell.

Get-PSDrive

This Get-PSDrive provides all the Cmdlets for us to work with Windows PowerShell Drives.

To get a list of all the PowerShell Drives in Windows PowerShell, use Get-PSDrive.

Example

PS C:\ > Get-PSDrive

Windows PowerShell

Get-PSDrive -Syntax

To get the syntax of the Get-PSDrive, use “-Syntax” parameter

Example

PS C:\> Get-Command Get-PSDrive -Syntax

Windows PowerShell

-PSProvider FileSystem

To get all the PSDrives that are only supported by Windows PowerShell FileSystem

Example

PS C:\> Get-PSDrive -PSProvider FileSystem

Windows PowerShell

-PSProvider Registry

To get all the PSDrives that are only supported by Windows PowerShell Registry provider.

Example

PS C:\> Get-PSDrive -PSProvider Registry

Windows PowerShell

Create a New -PSDrive

To create an new Windows PowerShell Drive, use New-PSDrive Cmdlet.

Example

PS C:\> New-PSDrive -Name PowerShellDrive -PSProvider FileSystem -Root :”C:\Vemulawada”

Windows PowerShell

[ You need to provide three parameters here, 1) Name of the New PSDrive, 2) PSProvider 3) The root, that is, the path to the root of the new drive ]

To Verify / View a PSDrive

After creating a PSDrive, if you want to list it, use Get-PSDrive and Provide your PSDrive name using -Name parameter.

Example

PS C:\> Get-PSDrive -Name PowerShellDrive.

Windows PowerShell

Delete a PowerShell Drive

To delete a PowerShell Drive, use Remove-PSDrive cmdlet.

Example

PS C:\> Remove-PSDrive -Name PowerShellDrive

Windows PowerShell

Note

Here, “PowerShellDrive” is the name of the PSDrive I created before.


Similar Articles