Created
February 8, 2019 16:26
-
-
Save chrisATautomatemystuff/45b3d80f33a6bc1d312356213ae26470 to your computer and use it in GitHub Desktop.
This file contains 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
#CREATE HOME DIRECTORY | |
New-Item -Path $homeDirectory -ItemType Directory -Force | |
#APPLY PERMISSIONS TO HOME FOLDER | |
$identityReference = $domainName + '\' + $samAccountName | |
$fileSystemAccessRights = [System.Security.AccessControl.FileSystemRights]::Modify | |
$inheritanceFlags = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit | |
$propagationFlags = [System.Security.AccessControl.PropagationFlags]::None | |
$accessControl = [System.Security.AccessControl.AccessControlType]::Allow | |
$accessRuleSplat = $identityReference, $fileSystemAccessRights, $inheritanceFlags, $propagationFlags, $accessControl | |
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $accessRuleSplat | |
$homeDirectoryACL = Get-Acl $homeDirectory | |
$homeDirectoryACL.AddAccessRule($accessRule) | |
Set-Acl -Path $homeDirectory -AclObject $homeDirectoryACL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment