Script repository

Create home folder for AD group

Updated on: Jan 18, 2026, Views: 6934

Folders and profiles

The script creates a folder for an AD group and grants the group full access permissions for the folder. To execute the script, create a business rule, custom command or scheduled task configured for the Group object type.

In the script, the $folderPath variable specifies a path to the folder that will be created.

$folderPath = "\\Server\Share\%name%" # TODO: modify me

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

# Grant Full Access permissions to the group.
$aclObj = Get-Acl $folder
$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")
$aclObj.AddAccessRule($acl)
Set-Acl -path $folder $aclObj

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    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.