Avatar of Isaiah Melendez
Isaiah Melendez
 asked on

Powershell 3.0 - Add Group/Username and Enable Full Control permissions

I am needing a script to add in a user. Let's say everyone into the security properties of a directory.

Directory: C:\CBASYNC
User: Everyone
Permissions needed: Full Control

How would I write this out in powershell?
ps_properties.png
PowershellSecurity

Avatar of undefined
Last Comment
Chris Dent

8/22/2022 - Mon
Chris Dent

This creates and adds the access control entry.
$acl = Get-Acl "C:\CBASYNC"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(
    'Everyone',
    'FullControl',
    'ObjectInherit,ContainerInherit',
    'None',
    'Allow'
)
$acl.AddAccessRule($accessRule)
Set-Acl "C:\CBASYNC" -AclObject $acl

Open in new window

ASKER CERTIFIED SOLUTION
Chris Dent

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61