Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Removing BUILTIN\Users permissions using powershell

$
0
0

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.



Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>