Compare commits

...

2 Commits

Author SHA1 Message Date
Karl-Wilfried Zimmer
b243ac2a36 snap: smb share creation possible without any specification of access rights 2024-07-14 18:21:40 +02:00
Karl-Wilfried Zimmer
13cf824507 snap: foldercreation working, problems with creating share 2024-07-14 17:47:06 +02:00

View File

@ -12,6 +12,14 @@ $ret=$null
$acls=$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("Server")){
$ret = New-ADGroup -Path $Projects -Server $Server -Name $ProjectName -GroupCategory Security -GroupScope Global -PassThru
@ -32,21 +40,34 @@ if($PSBoundParameters.ContainsKey("ProjectName")){
}
if($PSBoundParameters.ContainsKey("Server")){
$target = $acls | Where-Object Name -Match ".*RW"
$member = $rs | Where-Object Name -Match ".*RW"
$target = $acls | Where-Object Name -Match ".*-RW"
$member = $rs | Where-Object Name -Match ".*-RW"
Add-ADGroupMember -Identity $target -Members $member -Server $Server
$target = $acls | Where-Object Name -Match ".*RW"
$member = $rs | Where-Object Name -Match ".*RW"
$target = $acls | Where-Object Name -Match ".*-RO"
$member = $rs | Where-Object Name -Match ".*-RO"
Add-ADGroupMember -Identity $target -Members $member -Server $Server
} else {
$target = $acls | Where-Object Name -Match ".*RW"
$member = $rs | Where-Object Name -Match ".*RW"
$target = $acls | Where-Object Name -Match ".*-RW"
$member = $rs | Where-Object Name -Match ".*-RW"
Add-ADGroupMember -Identity $target -Members $member
$target = $acls | Where-Object Name -Match ".*RW"
$member = $rs | Where-Object Name -Match ".*RW"
$target = $acls | Where-Object Name -Match ".*-RO"
$member = $rs | Where-Object Name -Match ".*-RO"
Add-ADGroupMember -Identity $target -Members $member
}
$folder = New-Item -Path $projPath -ItemType Directory
$ReadTarget = $acls | Where-Object Name -Match ".*RW"
$WriteTarget = $acls | Where-Object Name -Match ".*RO"
$Parameters = @{
Name=$ProjectName
Path=$projPath
}
$share = New-SmbShare @Parameters
$share|Set-SmbShare -FolderEnumerationMode AccessBased
return $ret