相关疑难解决方法(0)

在 Windows 10 上使用 powershell 断开与 smb 共享的连接

我尝试在 Windows 10 中使用 Powershell 命令断开 smb 共享:

net use * /delete
Run Code Online (Sandbox Code Playgroud)

但是,此命令不起作用,因为共享未显示为net use。输出是There are no entries in the list.

Get-SmbConnection显示了我期望的结果,

ServerName ShareName UserName  Credential Dialect NumOpens
---------- --------- --------  ---------- ------- --------
FILESERVER extra     xxx\xxxxx xxx\xxxxx  3.0     1
FILESERVER home      xxx\xxxxx xxx\xxxxx  3.0     1
FILESERVER IPC$      xxx\xxxxx xxx\xxxxx  3.0     0
FILESERVER public    xxx\xxxxx xxx\xxxxx  3.0     2
Run Code Online (Sandbox Code Playgroud)

但我不知道如何断开与此信息的共享。

我的问题的原因:我想编写一个批处理脚本,在注销后断开所有网络共享与 PC 的连接(例如 Win+L 键)。在 Windows 7 和 8 上,我使用上述net use * /delete命令,该命令在 Windows 10 上不起作用,如上所示。SMB …

samba powershell network-shares windows-10

8
推荐指数
1
解决办法
2万
查看次数

从命令提示符列出 SMB 网络共享和进行身份验证的用户名

从命令提示符列出网络共享中所述,在命令提示符 ( cmd.exe) 中,我可以使用以下命令列出可用的网络共享:

net view \\computer
Run Code Online (Sandbox Code Playgroud)

就我而言,这给出了类似的内容:

C:\Users\user> net view \\COMPUTERNAME
Shared resources at \\COMPUTERNAME

TEST-FILE

Share name             Type  Used as  Comment

-------------------------------------------------------------------------------
archive                Disk           Fileserver
myfiles                Disk           Fileserver
MyShare                Disk  (UNC)
...
Run Code Online (Sandbox Code Playgroud)

但是,如果您键入net use并按 Enter 键,您应该会获得当前连接到的所有网络共享的列表。- 就我而言,我得到:

$ net use
New connections will be remembered.


Status       Local     Remote                    Network

-------------------------------------------------------------------------------
OK                     \\COMPUTERNAME\MyShare      Microsoft Windows Network
OK                     \\COMPUTERNAME\IPC$         Microsoft Windows Network
The command completed successfully.
Run Code Online (Sandbox Code Playgroud)

通常,每当我想要访问\\COMPUTERNAME但未经过身份验证时,我都需要使用登录名和密码进行身份验证。

因此,如果身份验证对话框未显示,则意味着我已经登录 - …

samba network-shares command-line windows-10

5
推荐指数
1
解决办法
1万
查看次数