PowerShell:如何创建文件共享
对我来说,文件共享的图形界面非常糟糕。因此,本文展示了如何在 PowerShell 中创建网络共享。
我们需要两个命令:New-SmbShare 和 Grant-SmbShareAccess。以下命令创建一个新共享并向每个人授予完全控制权。为什么要完全控制?它是 Microsoft 和 Best Practice 推荐的。请考虑:慷慨地分配共享权限并严格分配 NTFS 权限。 ?
让我们继续使用 PowerShell One-Liner。
New-SmbShare -Name Data -Path C:\Data | Grant-SmbShareAccess -AccountName Everyone -AccessRight Full要进行检查,请运行 Get-SmbShareAccess 和 Get-SmbShare。
style="font-family:Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', 'Courier 10 Pitch', Courier, monospace;">Get-SmbShareAccess -Name DataGet-SmbShare
