如何使用PowerShell删除映射的网络驱动器?
要从Windows系统上的PowerShell中删除映射的驱动器,可以同时使用PowerShell和cmd命令。
使用cmd命令
通过指定磁盘驱动器号或使用通配符(*),可以将以下命令用于单个映射的驱动器。
删除单个映射的驱动器。
示例
net use K: /delete
输出结果
PS C:\WINDOWS\system32> net use K: /delete K: was deleted successfully.
一起删除多个映射的驱动器。
示例
net use * /delete
您需要确认一起删除多个映射磁盘。
输出结果
PS C:\WINDOWS\system32> net use * /delete
You have these remote connections:
K: \\remoteshare\shared
M: \\remoteshare\shared folder
Continuing will cancel the connections.
Do you want to continue this operation? (Y/N) [N]: Y
The command completed successfully.使用PowerShell方法
若要使用PowerShell命令删除映射的网络驱动器,需要在cmdlet中提供驱动器号。如果要一起删除多个驱动器,请用逗号(,)隔开。
Remove-PSDrive K,M –Force -Verbose PS C:\WINDOWS\system32> Remove-PSDrive K,M -Force -Verbose VERBOSE: Performing the operation "Remove Drive" on target "Name: K Provider: Microsoft.PowerShell.Core\FileSystem Root: K:\". VERBOSE: Performing the operation "Remove Drive" on target "Name: M Provider: Microsoft.PowerShell.Core\FileSystem Root: M:\".
或者,您可以使用Get-PSDrive和管道Remove-PSDrive命令来删除它们,以获取映射的驱动器。
Get-PSDrive K,M | Remove-PSDrive -Force -Verbose
输出结果
PS C:\WINDOWS\system32> Get-PSDrive K,M | Remove-PSDrive -Force -Verbose VERBOSE: Performing the operation "Remove Drive" on target "Name: K Provider: Microsoft.PowerShell.Core\FileSystem Root: K:\". VERBOSE: Performing the operation "Remove Drive" on target "Name: M Provider: Microsoft.PowerShell.Core\FileSystem Root: M:\".
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短