Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Delete permissions on a folder.

$
0
0

Hello everyone,

 

I need to delete all user and group permissions from a folder. Unfortunately Powershell doesn't want to accept my wildcard * to delete everyone. Is there a way to delete everyone's permission from that folder?

What I have now:

 

$homedir="ipsum\ipsum2\martijn"#Delete Inheritance (WORKS)$acl= get-acl $homedir$isProtected=$true$preserveInheritance=$true$acl.SetAccessRuleProtection($isProtected, $preserveInheritance) 
Set-Acl -Path $homedir-AclObject $acl#Delete the permissions (DOESN'T WORK)$acl= get-acl $homedir$account= new-object system.security.principal.ntaccount("*")$acl.purgeaccessrules($account)
set-acl -aclobject $acl-path $homedir

 

As you can see I already deleted the Inheritance but still need to delete ALL of the permissions on the folder. This line gives an error:

$account= new-object system.security.principal.ntaccount("*")

Because it doesn't know what I mean with the wildcard *. So does anyone know how I can do this with only Powershell 2.0 and nothing else?

 


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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