3

我在创建共享或分配权限时没有问题,但我很难真正完全访问它。我是服务器上的管理员,我正在尝试准备服务器以供其他用户访问,并且我目前正在尝试将权限设置为对所有人的完全访问权限。

问题是,当我尝试在共享中创建新文件/文件夹时,访问被拒绝。

是否有其他人在通过 powershell 进行共享时遇到此错误?

这是我一直在使用的代码:

function New-Share 
    {
        param (
        [parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Mandatory=$true, HelpMessage="No folder name specified")]
        [string]$FolderName,
        [parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Mandatory=$true, HelpMessage="No share name specified")]
        [string]$ShareName,
        [parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Mandatory=$false, HelpMessage="No description specified")]
        [string]$Description
        )
    $error.clear()
    # Check for folder; Create it if it doesn't exist
        If (!(Test-Path $FolderName)) 
            {
                New-Item $FolderName -type Directory | Out-Null
            }
            # Check for share; Create it if it doesn't exist
            $Shares=[WMICLASS]"WIN32_Share"
            if (!(Get-WMIObject Win32_share -filter "name='$ShareName'"))
                {
                $Shares.Create($FolderName,$ShareName,0,65535,$Description) | Out-Null
                if (!($error))
                    {
                    # Share created
                    return $true
                    } else {
                    # Error
                    return $false
                    }
                } else {
            # Share Exists
            return $false
            }
    }

我一直在用这个调用函数:

function bo.Share()
    {
        $domain = [Environment]::UserDomainName
        $BDrive = "$boDrive" + ":\SYNintviewer"
        New-Share -FolderName "$BDrive" -ShareName "SYNintviewer" -Description "SYNintviewer"
    }
4

1 回答 1

1

我实际上是自己完成的...

调用此函数改为有效:

function bo.Share()
{
    $domain = [Environment]::UserDomainName
    $BDrive = "$boDrive" + ":\SYNintviewer"
    echo "$boDrive is BoDRIVE"
    echo "$BDrive is BDRIVE"
    New-Share -Sharename "SYNintviewer" -Sharepath "$BDrive" -group "Authenticated Users" -auth FULL
}
于 2012-10-18T15:12:25.733 回答