none
Removing BUILTIN\Users permissions using powershell RRS feed

  • Question

  • Hello! This would be one of my first posts on this forum, I recently started Powershell not too long ago so I'm still a beginner.

    I'm trying to make a script that strips the BUILTIN\Users of rights from a folder, my script goes as follows.

    #creates a folder in apps

    New-Item -Path "C:\apps" -Name "$client" -ItemType "directory"

    #disable inheritance

    $acl = Get-Acl -Path c:/apps/$client
    $acl.SetAccessRuleProtection($True, $True)
    $acl |Set-Acl

    #attempt at removing read and write

    $ace = $acl.Access| where IdentityReference  -eq "BUILTIN\Users" | where FileSystemRights -EQ "ReadAndExecute, Synchronize"
    $acl.RemoveAccessRule($ace)
    $acl | Set-Acl -Path c:/apps/$client

    This doesn't remove the permissions off the file. I'd like to if possible completely remove BUILTIN\Users from the permissions list.

    I'm unsure how to do this, any help is appreciated.


    Tuesday, February 4, 2020 2:29 PM

Answers

All replies