Last active
July 20, 2024 21:50
-
-
Save elico/4bff0d9bda162f0c0c2a3b76a585b885 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
$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