Skip to content

Instantly share code, notes, and snippets.

@elico
Last active July 20, 2024 21:50
Show Gist options
  • Save elico/4bff0d9bda162f0c0c2a3b76a585b885 to your computer and use it in GitHub Desktop.
Save elico/4bff0d9bda162f0c0c2a3b76a585b885 to your computer and use it in GitHub Desktop.
$path = "C:\Users\eliez"
### First give system permissions
$identity = "SYSTEM"
$acl = Get-Acl -Path $path
$ace = New-Object System.Security.Accesscontrol.FileSystemAccessRule ($identity, "FullControl", "Allow")
$acl.AddAccessRule($ace)
Set-Acl -Path $path -AclObject $acl
## Give my user permissions
$identity = [System.Net.Dns]::GetHostName() +"\eliez"
$acl = Get-Acl -Path $path
$ace = New-Object System.Security.Accesscontrol.FileSystemAccessRule ($identity, "FullControl", "Allow")
$acl.AddAccessRule($ace)
Set-Acl -Path $path -AclObject $acl
## Give my Administrators group permissions
$identity = "BUILTIN\Administrators"
$path = "C:\Users\eliez"
$acl = Get-Acl -Path $path
$ace = New-Object System.Security.Accesscontrol.FileSystemAccessRule ($identity, "FullControl", "Allow")
$acl.AddAccessRule($ace)
Set-Acl -Path $path -AclObject $acl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment