Remove-PSDrive
Deletes temporary Windows PowerShell drives and disconnects mapped network drives.
Remove-PSDrive [-Name*] <String[]> [-Force] [-PSProvider [<String[]>]] [-Scope [<String>]] [-Confirm] [-WhatIf][-UseTransaction [<SwitchParameter>]] [<CommonParameters>]
Remove-PSDrive [-LiteralName*] <String[]> [-Force] [-PSProvider [<String[]>]] [-Scope [<String>]] [-Confirm][-WhatIf] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]
The Remove-PSDrive cmdlet deletes temporary Windows PowerShell drives that were created by using the New-PSDrive cmdlet.
Starting in Windows PowerShell 3.0, Remove-PSDrive also disconnects mapped network drives, including, but not limited to, drives created by using the Persist parameter of New-PSDrive.
Remove-PSDrive cannot delete Windows physical or logical drives.
Starting in Windows PowerShell 3.0, when an external drive is connected to the computer, Windows PowerShell automatically adds a PSDrive to the file system that represents the new drive. You do not have to restart Windows PowerShell. Similarly, when an external drive is disconnected from the computer, Windows PowerShell automatically deletes the PSDrive that represents the removed drive.
Parameters |
---|
-Force [<SwitchParameter>]
|
-LiteralName <String[]>
|
-Name <String[]>
|
-PSProvider [<String[]>]
|
-Scope [<String>]
|
-Confirm [<SwitchParameter>]
|
-WhatIf [<SwitchParameter>]
|
-UseTransaction [<SwitchParameter>]
|
<CommonParameters>
|
Inputs
System.Management.Automation.PSDriveInfo
You can pipe a drive object, such as one from the Get-PSDrive cmdlet, to the this cmdlet.
Outputs
None
This cmdlet does not return any output.
Examples
- Remove a file system drive:
PS C:> Remove-PSDrive -Name smp
This command removes a temporary file system drive named smp.
- Remove mapped network drives:
PS C:> Get-PSDrive X, S | Remove-PSDrive
This command disconnects the X: mapped network drive that was created in File Explorer and the S: mapped network drive that was created by using the Persist parameter of the New-PSDrive cmdlet.
The command uses the Get-PSDrive cmdlet to get the drives and Remove-PSDrive to disconnect them.
Additional Notes
Remove-PSDrive is designed to work with the data exposed by any Windows PowerShell provider. To list the providers in your session, use the Get-PSProvider cmdlet. For more information, see about_Providers (http://go.microsoft.com/fwlink/?LinkID=113250).
Related Links