我有一个脚本,我想在创建新的PSDrive之前断开与映射驱动器的连接 .
否则我收到此错误:
New-PSDrive:不允许同一用户使用多个用户名与服务器或共享资源 Build 多个连接 . 断开与服务器或共享资源的所有先前连接,然后重试
所以我有这条线:
net use * /delete
(遗憾的是,到目前为止,我无法通过提供服务器名称来找到与特定映射驱动器断开连接的方法:()
当PS来到这条线
您有以下远程连接:\ ServerName \ SharedFolder继续将取消连接 .
然后它停止执行 .
Is there a way to auto confirm disconnecting from the mapped drives automatically without confirmation (it does not have to be the net use /delete solution)?
Note that :我从Powershell ISE PS promt运行我的脚本
1 回答
试试这个:
/y
键使其在静默提示中选择“是”