我正在编写一个PowerShell脚本,它将在c驱动器上设置文件夹结构,然后将这些文件夹转换为共享。
使用New-SmbShare
cmdlet时,我收到1332或50错误。
使用域我得到1332错误
New-SmbShare -Name "InstallerFiles" -Path "C:\SoftwareDistribution\InstallerFiles" -ContinuouslyAvailable $true -ReadAccess "domain\Authenticated Users"
New-SmbShare : No mapping between account names and security IDs was done.
At line:1 char:1
+ New-SmbShare -Name "InstallerFiles" -Path "C:\SoftwareDistribution\InstallerFile ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_SMBShare:ROOT/Microsoft/Windows/SMB/MSFT_SMBShare) [New-SmbShare], CimException
+ FullyQualifiedErrorId : Windows System Error 1332,New-SmbShare
如果删除域名,我会收到50错误。
New-SmbShare -Name "InstallerFiles" -Path "C:\SoftwareDistribution\InstallerFiles" -ContinuouslyAvailable $true -ReadAccess "Authenticated Users"
New-SmbShare : The request is not supported.
At line:1 char:1
+ New-SmbShare -Name "InstallerFiles" -Path "C:\SoftwareDistribution\InstallerFile ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (MSFT_SMBShare:ROOT/Microsoft/Windows/SMB/MSFT_SMBShare) [New-SmbShare], CimException
+ FullyQualifiedErrorId : Windows System Error 50,New-SmbShare
如果删除-ContinuouslyAvailable
和-ReadAccess
,我就可以创建共享,但我希望能够从脚本中分配用户或安全组权限。
为了设置smb共享并使用PowerShell分配用户或安全组,我需要更改哪些内容?
答案 0 :(得分:6)
您需要删除-ContinuouslyAvailable
标记。据我所知,无论如何,此标志默认设置为True。
您可能还想看看这些:
由于该功能可能在您的环境中不可用,因此New-SmbShare : The request is not supported.
错误
并且您的第一个错误:No mapping between account names and security IDs was done
,我相信这基本上意味着"用户未找到"看到这里:
也许可以从这里试试这个例子: