snap: foldercreation working, problems with creating share
This commit is contained in:
parent
27548c5dc5
commit
13cf824507
@ -32,22 +32,43 @@ 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
|
||||
}
|
||||
|
||||
$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
|
||||
|
||||
$ReadTarget = $acls | Where-Object Name -Match ".*RW"
|
||||
$WriteTarget = $acls | Where-Object Name -Match ".*RO"
|
||||
|
||||
$Parameters = @{
|
||||
Name=$ProjectName
|
||||
Path=$projPath
|
||||
ChangeAccess=$WriteTarget.SID
|
||||
ReadAccess=$ReadTarget.SID
|
||||
}
|
||||
|
||||
$share = New-SmbShare @Parameters
|
||||
$share|Set-SmbShare -FolderEnumerationMode AccessBased
|
||||
}
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user