I have to create a set of folders based on an address list and then configure the permissions in active directory. Creating the folders and subfolders works for me, I adapted a few lines I found online:
This creates the folders based on the address list.
$FolderNames = Get-Content -Path "E:\Data\addresses.txt"
$DirectoryPath = "E:\Data\buildings"
ForEach ($FolderName in $FolderNames)
{
New-Item -ItemType Directory -Path (Join-Path -Path $DirectoryPath -ChildPath $FolderName)
}
This creates the subfolders
$FolderNames = "E:\Data\addresses.txt"
New-item "E:\Data\buildings\$env:foldernames\*" -Name "Patrimonium" -ItemType Directory
New-item "E:\Data\buildings\$env:foldernames\*" -Name "Social Services" -ItemType Directory
New-item "E:\Data\buildings\$env:foldernames\*" -Name "Administration" -ItemType Directory
New-item "E:\Data\buildings\$env:foldernames\*" -Name "Patrimonium\subfolder1" -ItemType Directory
New-item "E:\Data\buildings\$env:foldernames\*" -Name "Patrimonium\subfolder2" -ItemType Directory
New-item "E:\Data\buildings\$env:foldernames\*" -Name "Social Services\subfolder1" -ItemType Directory
New-item "E:\Data\buildings\$env:foldernames\*" -Name "Social Services\subfolder2" -ItemType Directory
New-item "E:\Data\buildings\$env:foldernames\*" -Name "Administration\subfolder" -ItemType Directory
New-item "E:\Data\buildings\$env:foldernames\*" -Name "Administration\subfolder2" -ItemType Directory
So now I want to disabele inheritance and set an ACL for every subfolder named "Patrimonium", "Social Services", "Administration". Every folder has it's own security group. The subfolders below that need to inherit permissions. Honestly I don't know where to start. Is it even possible?