如何使用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:\".
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短