Difference between revisions of "Modifying home directory permissions"

From MyWiki
Jump to: navigation, search
(Created page with " <source lang="powershell"> $HomeFolders = Get-ChildItem C:Homefolders -Directory foreach ($HomeFolder in $HomeFolders) { $Path = $HomeFolder.FullName $Acl = (Get-It...")
(No difference)

Revision as of 15:46, 7 June 2017


$HomeFolders = Get-ChildItem C:Homefolders -Directory
foreach ($HomeFolder in $HomeFolders) {
    $Path = $HomeFolder.FullName
    $Acl = (Get-Item $Path).GetAccessControl('Access')
    $Username = $HomeFolder.Name
    $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($Username, 'Modify',                 'ContainerInherit,ObjectInherit', 'None', 'Allow')
    $Acl.SetAccessRule($Ar)
    Set-Acl -path $Path -AclObject $Acl
}