Last active
March 4, 2018 06:09
-
-
Save Agazoth/0a58f882ba788ab11c1dd3f4a0d55e19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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