diff --git a/NewProject.ps1 b/NewProject.ps1 index 42b5fd6..e322f3b 100644 --- a/NewProject.ps1 +++ b/NewProject.ps1 @@ -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 }