Created
April 26, 2018 22:39
-
-
Save Chirishman/e3fbbc3dc42e21bbdfa56409f559b99b to your computer and use it in GitHub Desktop.
Script to correct home folder permissions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
$HomeFoldersDirectoryPath = 'C:\Default\Path\Here\' | |
) | |
$HomeFolders = Get-ChildItem $HomeFoldersDirectoryPath -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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: http://www.tomsitpro.com/articles/powershell-manage-file-system-acl,2-837.html