Skip to content

Instantly share code, notes, and snippets.

@Chirishman
Created April 26, 2018 22:39
Show Gist options
  • Save Chirishman/e3fbbc3dc42e21bbdfa56409f559b99b to your computer and use it in GitHub Desktop.
Save Chirishman/e3fbbc3dc42e21bbdfa56409f559b99b to your computer and use it in GitHub Desktop.
Script to correct home folder permissions
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
}
@Chirishman
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment