Forum Discussion
Nitrox
Oct 28, 2022Copper Contributor
Script to add an AD Security group to multiple User Home drive folders
Hi All I'm trying to put together a script to perform the following task: First to add an AD Security Group named "ADMigration" and assign it (Read access) to a large list of User Home Drives...
ChrisBradshaw
Mar 22, 2023Iron Contributor
If you're still looking to solve this, hopefully this will get you started. The Set-ACL syntax you want will be something like:
$HomeFolderPath="X:\Path\To\Home\Folder"
#Get Existing Permissions
$NewAcl=Get-Acl -Path $HomeFolderPath
# Set properties
$identity = "ADMigration"
$fileSystemRights = "Read"
$type = "Allow"
# Create new rule
$fileSystemAccessRuleArgumentList = $identity, $fileSystemRights, $type
$fileSystemAccessRule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $fileSystemAccessRuleArgumentList
# Apply new rule
$NewAcl.SetAccessRule($fileSystemAccessRule)
Set-Acl -Path $HomeFolderPath -AclObject $NewAcl
If this works for you, the next step would be to wrap it up in a loop, reading the Home Drive paths from your list.