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