We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script Repository

Create home folder for AD group

March 18, 2021 Views: 3326

The script creates a folder for an AD group and grants the group full access permissions for the folder.


  • $folderPath - Specifies a full path to the folder that will be created. You can use value references (e.g. %name%) in the path. They will be replaced with corresponding property values of the group object.
Edit Remove
$folderPath = "\\Server\Share\%name%" # TODO: modify me

# Create folder
    $folder = New-Item -Path $folderPath -ItemType Directory -ErrorAction Stop
    $Context.Cancel("An error occurred while creating a folder for the group. Error: " + $_.Exception.Message)

# Update folder permissions
$aclObj = Get-Acl $folder

# Grant Full Access permissions to the group
$groupSidBinary = $Context.TargetObject.Get("objectSid")
$groupSid = New-Object System.Security.Principal.SecurityIdentifier($groupSidBinary, 0)
$acl = New-Object System.Security.AccessControl.FileSystemAccessRule($groupSid, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")

# Update folder permissions
Set-Acl -path $folder $aclObj
Comments 0
Leave a comment

Got questions?

Support Questions & Answers