This is cache of http://pluralsight.com/blogs/keith/archive/2008/01/09/49855.aspx. Cache is the snapshot of article that we took when we index feed.
To see original page click here.
We are not affiliated with the authors of this article and not responsible for its content.
Setting file ACLs with PowerShell part 5
2008-01-09 04:53:00 by Keith Brown in Security Briefs
 

In my previous post in this series, I showed how easy it is to work with enumerations in PowerShell. Here's the code I've been walking through in this series:

$dacl = (dir foo.txt).GetAccessControl()
$newRule = New-Object Security.AccessControl.FileSystemAccessRule "keith", Modify, Allow
$modified = $false
$dacl.ModifyAccessRule("Add", $newRule, [ref]$modified)
(dir foo.txt).SetAccessControl($dacl)

All I've got left to explain is the last line of code. It's important to note that when you're tweaking ACLs, there are basically three steps you have to take:

  1. Read the ACL from an object.
  2. Tweak it however you like.
  3. Write the ACL back to the object.

In this last line of code, I'm applying the new, tweaked ACL back to the file foo.txt. At this point the new access control policy takes effect.

Navigate posts in this series: prev

 
 
 
 
 
 
TOP SEARCH
Expand / MinimizeClose Widget
  •  
RECENT SEARCH
Expand / Minimize
  •  
RELATED VIDEO
Expand / Minimize
SecurityRatty FAQ
Sergey Zarubin, 31yo
CISSP, CCSP
Moscow, Russia