snap: smb share creation possible without any specification of access rights
This commit is contained in:
parent
13cf824507
commit
b243ac2a36
@ -12,6 +12,14 @@ $ret=$null
|
|||||||
$acls=$null
|
$acls=$null
|
||||||
$rs=$null
|
$rs=$null
|
||||||
|
|
||||||
|
$projPath=$BaseDirectory+$ProjectName
|
||||||
|
Write-Host $projPath
|
||||||
|
$testFolder = Test-Path -Path $projPath -PathType Container
|
||||||
|
|
||||||
|
if($testFolder){
|
||||||
|
throw "Directory already exists. Not creating Folder or Share"
|
||||||
|
}
|
||||||
|
|
||||||
if($PSBoundParameters.ContainsKey("ProjectName")){
|
if($PSBoundParameters.ContainsKey("ProjectName")){
|
||||||
if($PSBoundParameters.ContainsKey("Server")){
|
if($PSBoundParameters.ContainsKey("Server")){
|
||||||
$ret = New-ADGroup -Path $Projects -Server $Server -Name $ProjectName -GroupCategory Security -GroupScope Global -PassThru
|
$ret = New-ADGroup -Path $Projects -Server $Server -Name $ProjectName -GroupCategory Security -GroupScope Global -PassThru
|
||||||
@ -47,13 +55,7 @@ if($PSBoundParameters.ContainsKey("ProjectName")){
|
|||||||
Add-ADGroupMember -Identity $target -Members $member
|
Add-ADGroupMember -Identity $target -Members $member
|
||||||
}
|
}
|
||||||
|
|
||||||
$testFolder = Test-Path "$BaseDirectory+$ProjectName" -PathType Container
|
|
||||||
|
|
||||||
if($testFolder){
|
|
||||||
throw "Directory already exists. Not creating Folder or Share"
|
|
||||||
} else {
|
|
||||||
$projPath=$BaseDirectory+$ProjectName
|
|
||||||
Write-Host $projPath
|
|
||||||
$folder = New-Item -Path $projPath -ItemType Directory
|
$folder = New-Item -Path $projPath -ItemType Directory
|
||||||
|
|
||||||
$ReadTarget = $acls | Where-Object Name -Match ".*RW"
|
$ReadTarget = $acls | Where-Object Name -Match ".*RW"
|
||||||
@ -62,13 +64,11 @@ if($PSBoundParameters.ContainsKey("ProjectName")){
|
|||||||
$Parameters = @{
|
$Parameters = @{
|
||||||
Name=$ProjectName
|
Name=$ProjectName
|
||||||
Path=$projPath
|
Path=$projPath
|
||||||
ChangeAccess=$WriteTarget.SID
|
|
||||||
ReadAccess=$ReadTarget.SID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$share = New-SmbShare @Parameters
|
$share = New-SmbShare @Parameters
|
||||||
$share|Set-SmbShare -FolderEnumerationMode AccessBased
|
$share|Set-SmbShare -FolderEnumerationMode AccessBased
|
||||||
}
|
|
||||||
|
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user