Remove-PSDrive
删除临时 PowerShell 驱动器并断开映射的网络驱动器的连接。
语法
Remove-PSDrive
[-Name] <String[]>
[-PSProvider <String[]>]
[-Scope <String>]
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-PSDrive
[-LiteralName] <String[]>
[-PSProvider <String[]>]
[-Scope <String>]
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Remove-PSDrive
cmdlet 删除使用 New-PSDrive
cmdlet 创建的临时 PowerShell 驱动器。
从 Windows PowerShell 3.0 开始,Remove-PSDrive
还会断开映射网络驱动器的连接,包括但不限于使用 New-PSDrive
Persist 参数创建的驱动器。
Remove-PSDrive
无法删除 Windows 物理或逻辑驱动器。
从 Windows PowerShell 3.0 开始,当外部驱动器连接到计算机时,PowerShell 会自动将 PSDrive 添加到表示新驱动器的文件系统。 无需重启 PowerShell。 同样,当外部驱动器与计算机断开连接时,PowerShell 会自动删除表示已删除驱动器的 PSDrive。
示例
示例 1:删除文件系统驱动器
此命令删除名为 smp
的临时文件系统驱动器。
Remove-PSDrive -Name smp
示例 2:删除映射的网络驱动器
此命令使用 Remove-PSDrive
断开 X:
和 S:
映射网络驱动器的连接。
Get-PSDrive X, S | Remove-PSDrive
参数
-Confirm
在运行 cmdlet 之前,提示你进行确认。
类型: | SwitchParameter |
别名: | cf |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Force
删除当前的 PowerShell 驱动器。
类型: | SwitchParameter |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-LiteralName
指定驱动器的名称。
LiteralName 的值与类型完全相同。 不会将任何字符解释为通配符。
如果名称包含转义字符,请将它括在单引号('
)。 单引号指示 PowerShell 不要将任何字符解释为转义序列。
类型: | String[] |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Name
指定要删除的驱动器的名称。 不要在驱动器名称后面键入冒号(:
)。
类型: | String[] |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | True |
-PSProvider
指定 PSProvider 对象的数组。 此 cmdlet 删除并断开与指定 PowerShell 提供程序关联的所有驱动器的连接。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-Scope
指定驱动器的范围。 此参数的可接受值为:Global
、Local
和 Script
,或相对于当前范围的数字。 范围数 0
范围数。 当前范围编号为 0
,其父级为 1
。 有关详细信息,请参阅 about_Scopes。
类型: | String |
Position: | Named |
默认值: | Local |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-WhatIf
显示 cmdlet 运行时会发生什么情况。 cmdlet 未运行。
类型: | SwitchParameter |
别名: | wi |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
输入
可以通过管道将驱动器对象(例如从 Get-PSDrive
cmdlet)传递给此 cmdlet。
输出
None
此 cmdlet 不返回任何输出。
备注
PowerShell 包含以下 Remove-PSDrive
别名:
所有平台:
rdr
Remove-PSDrive
cmdlet 旨在处理任何 PowerShell 提供程序公开的数据。 若要列出会话中的提供程序,请使用Get-PSProvider
cmdlet。 有关详细信息,请参阅 about_Providers。