PowerShell - Add User/Group to UNC share Get-Acl
- Jon Boyette
- Jan 10, 2022
- 1 min read
Save as name.ps1, once ran, prompts for UNC to add group or user to, then the user/group by domain\user capable to add, then asks for read, modify, full rights defined
$c = Read-Host "Enter Share UNC Path"
$d = Read-Host "Enter Account Credentials domain\username to Add to Share"
$e = Read-Host "Enter Read, Modify or Full for Groups Access rights to Apply"
{
$acl = Get-Acl $c
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("$d","$e")
$acl.SetAccessRule($AccessRule)
$acl | Set-Acl \\Yourserver\Yourshare
}
Comments