为什么要“净使用* /删除”?无法正常工作,但需要等待PowerShell脚本中的确认? [英] Why "net use * /delete" does not work but waits for confirmation in my PowerShell script?

查看:97
本文介绍了为什么要“净使用* /删除”?无法正常工作,但需要等待PowerShell脚本中的确认?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建新的PSDrive之前,我有一个脚本要与映射的驱动器断开连接。

I have a script where I want to disconnect from the mapped drives before I create a new PSDrive.

否则,我会收到此错误:

Otherwise I get this error:


New-PSDrive:同一用户
使用多个用户名到服务器或共享资源的多个连接是不允许的。
断开与服务器或共享资源
的所有先前连接,然后重试

New-PSDrive : Multiple connections to a server or shared resource by the same user , using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again

所以我有这行:

net use * /delete

(不幸的是,仅通过提供到目前为止的服务器名称,我无法找到一种方法来断开与特定映射驱动器的连接:()

(Unfortunately I could not find a way to disconnect from a specific mapped drive just by providing the server name so far :( )

何时PS进入此行


您具有以下远程连接:

You have these remote connections:

\ \ServerName\SharedFolder继续将取消连接。

\\ServerName\SharedFolder Continuing will cancel the connections.

然后停止执行。

是否有一种无需确认即可自动确认与映射驱动器的断开连接的自动确认方式(不必是网络使用/删除解决方案)?

注意:我从Powershell ISE PS promt运行脚本。

Note that: I run my script from the Powershell ISE PS promt

推荐答案

尝试一下:

net use * /delete /y

/ y 键使其在无提示的提示下选择是

The /y key makes it select Yes in prompt silently

这篇关于为什么要“净使用* /删除”?无法正常工作,但需要等待PowerShell脚本中的确认?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆