Skip to content

Instantly share code, notes, and snippets.

@Agazoth
Last active March 4, 2018 06:09
Show Gist options
  • Save Agazoth/0a58f882ba788ab11c1dd3f4a0d55e19 to your computer and use it in GitHub Desktop.
Save Agazoth/0a58f882ba788ab11c1dd3f4a0d55e19 to your computer and use it in GitHub Desktop.
$File = New-Item -ItemType File -Path c:\SpecialFolder\SpecialFile.txt -Force
$Bill = New-LocalUser "Bill Bennsson" -Password (ConvertTo-SecureString -String BillAdmin -AsPlainText -Force)
$Andy = New-LocalUser "Andy Pandien" -Password (ConvertTo-SecureString -String AndyUser -AsPlainText -Force)
$Access = [System.Security.AccessControl.FileSystemAccessRule]::new($Bill.SID,"Modify","Allow"),[System.Security.AccessControl.FileSystemAccessRule]::new($Andy.SID,"Read","Allow")
$NewACL=[System.Security.AccessControl.DirectorySecurity]::new()
$NewACL.SetSecurityDescriptorSddlForm('D:')
$NewACL.SetAccessRuleProtection($True, $True)
$Access | ForEach-Object {$NewACL.AddAccessRule($_)}
Set-Acl $File.FullName $NewACL
iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/Agazoth/0a58f882ba788ab11c1dd3f4a0d55e19/raw/e55e00016780d17cd2350d9daa5a75b94d2663e5/BillAndAndysFile.ps1'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment