Roaming Profile Permissions


I have some issues with setting permissions on newly created folders. Found some solutions online but all of them are a bit different and I can’t get it to work. This is how I set it up for now (partial of the script, as the full script is ~1000 lines long)

The function which should set the permissions:

function set-folderPermissions { param( [string]$foldername = $null, [string]$username = $null, [string]$permission = "FullControl", [string]$permissionInheritance = "ContainerInherit, ObjectInherit", [string]$permissionPropagation = "None", [string]$permissionType = "Allow" ) $Acl = Get-Acl "$foldername" $Ar = New-Object$username,$permission,$permissionInheritance) $Acl.SetAccessRule($Ar) Set-Acl $foldername $Acl } 

The (various) folders:

$profilePathS = "\something.localsomethingUserProfilessomething" $profilePathL = "\something.localsomethingUserProfilessomethingelse" $homePathS = "\something.localsomethingUserDatasomething" $homePathL = "\something.localsomethingUserDatasomethingelse" 

And the part in which the folders are created and permissions should be set:

$profileDirS = new-item -path "$($profilePathS)$($user.sam)" -ItemType Directory set-folderPermissions -foldername $profileDirS -username $user.sam $homeDirS = new-item -path "$($homePathS)$($user.sam)" -ItemType Directory set-folderPermissions -foldername $homeDirS -username $user.sam 

The folders are created but no permissions are set. I also don’t get any errors, so I really don’t see where everything goes wrong :/

submitted by /u/ChaschNoSchnell
[link] [comments]

Leave a Reply