用 Remove-SmbShare 取消文件夹共享
先用 Get-SmbShare 列出所有共享,再用 Remove-SmbShare -Force 停止不需要的共享,文件本身不受影响。
运行 Get-SmbShare 查看共享列表,然后 Remove-SmbShare -Name 'Reports' -Force 取消指定共享。
01命令
命令
$ Get-SmbShare | Format-Table Name, Path -AutoSize
Remove-SmbShare -Name 'Reports' -Force02作用说明
删除共享只是让文件夹不再出现在网络上,文件和 NTFS 权限原样保留;ADMIN$、C$ 这类隐藏系统共享由 Windows 管理,不要去删。共享被删除时访问权限列表也会一起消失,如果想以后重新共享,先记下当前权限。顺手用 Get-SmbShare 审计一遍共享列表,在接手二手电脑或中过病毒后尤其值得做。
03风险
!注意: 正在从共享复制文件的客户端会报错;建议等传输完成或提前通知。
04撤销
撤销
$ Re-create it with New-SmbShare (the access list is deleted with the share, so note it beforehand).05来源
- Remove-SmbShare依据: Remove-SmbShare deletes an SMB share by name; -Force suppresses the confirmation prompt.
- SmbShare module - SS64依据: Lists Get-SmbShare for auditing shares and Remove-SmbShare for deleting them.
最后验证: 2026-09-18 · 分类: 文件与文件夹