| external help file | Microsoft.PowerShell.Commands.Management.dll-Help.xml | |
|---|---|---|
| Locale | en-US | |
| Module Name | Microsoft.PowerShell.Management | |
| ms.date | 01/18/2023 | |
| online version | https://learn.microsoft.com/powershell/module/microsoft.powershell.management/remove-psdrive?view=powershell-7.6&WT.mc_id=ps-gethelp | |
| schema | 2.0.0 | |
| aliases |
|
|
| title | Remove-PSDrive |
Deletes temporary PowerShell drives and disconnects mapped network drives.
Remove-PSDrive [-Name] <String[]> [-PSProvider <String[]>] [-Scope <String>] [-Force]
[-WhatIf] [-Confirm] [<CommonParameters>]
Remove-PSDrive [-LiteralName] <String[]> [-PSProvider <String[]>] [-Scope <String>] [-Force]
[-WhatIf] [-Confirm] [<CommonParameters>]
The Remove-PSDrive cmdlet deletes temporary PowerShell drives that were created by using the
New-PSDrive cmdlet.
Beginning 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.
Beginning in Windows PowerShell 3.0, when an external drive is connected to the computer, PowerShell automatically adds a PSDrive to the file system that represents the new drive. You do not need to restart PowerShell. Similarly, when an external drive is disconnected from the computer, PowerShell automatically deletes the PSDrive that represents the removed drive.
This command removes a temporary file system drive named smp.
Remove-PSDrive -Name smpThis command uses Remove-PSDrive to disconnect the X: and S: mapped network drives.
Get-PSDrive X, S | Remove-PSDriveRemoves the current PowerShell drive.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the name of the drive.
The value of LiteralName is used exactly as typed. No characters are interpreted as wildcards.
If the name includes escape characters, enclose it in single quotation marks ('). Single quotation
marks instruct PowerShell not to interpret any characters as escape sequences.
Type: System.String[]
Parameter Sets: LiteralName
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseSpecifies the names of the drives to remove. Do not type a colon (:) after the drive name.
Type: System.String[]
Parameter Sets: Name
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: TrueSpecifies an array of PSProvider objects. This cmdlet removes and disconnects all of the drives associated with the specified PowerShell provider.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseSpecifies a scope for the drive. The acceptable values for this parameter are: Global, Local,
and Script, or a number relative to the current scope. Scopes number 0 through the number of
scopes. The current scope number is 0 and its parent is 1. For more information, see
about_Scopes.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Local
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalsePrompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseShows what would happen if the cmdlet runs. The cmdlet is not run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
You can pipe a drive object, such as from the Get-PSDrive cmdlet, to this cmdlet.
This cmdlet returns no output.
PowerShell includes the following aliases for Remove-PSDrive:
-
All platforms:
rdr
-
The
Remove-PSDrivecmdlet is designed to work with the data exposed by any PowerShell provider. To list the providers in your session, use theGet-PSProvidercmdlet. For more information, see about_Providers.