Created
February 4, 2020 14:02
-
-
Save pcrockett-pathway/36480ce5a8af1eed248813733c88222c to your computer and use it in GitHub Desktop.
Create a directory and lock down permissions so only the current user has access to it
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
New-Item -ItemType Directory $configDir | Out-Null | |
$acl = Get-Acl $configDir | |
$acl.SetAccessRuleProtection($True, $False) # Clear all access rules, disable permission inheritance | |
$currentUser = [Security.Principal.NTAccount]::new($env:USERNAME) | |
$acl.SetOwner($currentUser) | |
$accessRule = [Security.AccessControl.FileSystemAccessRule]::new($currentUser, "FullControl", "Allow") | |
$acl.SetAccessRule($accessRule) | |
Set-Acl -Path $configDir -AclObject $acl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment