我在创建共享或分配权限方面没有问题,但我真的很难实际完全访问它。我是服务器的管理员,我正在尝试测试准备服务器以供其他用户访问,我正在尝试将权限设置为现在可以完全访问所有人。
问题在于,当我尝试在共享中创建新文件/文件夹时,我被拒绝访问。
通过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"
}
答案 0 :(得分: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
}