September 27

Powershell Script to Grand user Home Folder permissions

$OU=”OU=kindergarten,OU=sales,OU=Students,OU=Users,OU=MonSchool,OU=Schools,OU=abcdUsers,DC=abcd,DC=ef,DC=com

$Group1=”CN=Students Ktest,OU=Groups,OU=abcUsers,DC=abcd,DC=ef,DC=com

Get-ADUser –SearchBase $OU –SearchScope 1 –LDAPFilter “(memberOf=$Group1)” | ForEach-Object { icacls “$(Join-Path ‘\\servera\sharedfolder\’ $_.SamAccountName)” /grant “$($_.SamAccountName):(OI)(CI)F” }

* Group1 is the group that the users belong to

NOTE: You can change the SearchScope to search the current path and all the children paths.
-SearchScope

Specifies the scope of an Active Directory search. The acceptable values for this parameter are:

  • Base or 0
  • OneLevel or 1
  • Subtree or 2

A Base query searches only the current path or object. A OneLevel query searches the immediate children of that path or object. A Subtree query searches the current path or object and all children of that path or object.