locked
Create home drive sub-folder and apply permissions RRS feed

  • Question

  • Need to create a sub-folder in each users home drive on server. I think straightforward to create folder with new-item but how can I apply the permissions correctly?. Folder names are logon name so Fed Bloggs would have folder Bloggsf so I would want to give modify right to that user (which is not inherited user only has list access to their root and modify to the precreated sub-folders)

    Ian Burnell, London (UK)

    Thursday, February 7, 2019 9:16 AM

All replies

  • Your task is very easy.  I guess some of suggestions (except general answer like "post your code") will contain SET-ACL cmdlet.. which I don't like much … :)

    I do like using old fashioned ICACLS command, for me its very readable and understandable..

    Example

    $strGrant	= "/grant"
    $strRemove = "/remove"
    $Icaclsparam1	= ":(OI)(CI)(F)"
    $Icaclsparam2	= ":(OI)(CI)(IO)(F)"
    $Icaclsparam3	= ":(OI)(CI)(RX,W,DC)"
    $Icaclsparam4	= ":(OI)(CI)(RX)"
    $Icaclsparam5	= ":(RX)"
    $Icaclsparam6	= ":(CI)"
    
    $OBJ1		= "Domain\User1"
    
    Invoke-Expression -Command ('icacls D:\Home\Folder1 $strGrant "${OBJ1}${Icaclsparam1}"')

    All u need to do is

    1. get folder structure
    2. create loop   (get some info about powershell loops)
    3. paste your scriptblock which will modify permissions for each folder.

    Thursday, February 7, 2019 10:27 AM
  • Example setting folder perms:

    foreach ($dir in $dirs)
    {
     $params = ":(OI)(CI)(F)" #grants full access
     $grant = "/grant"
     $to = "domain\$dir"
     Invoke-Expression -Command ('icacls $dir $grant "${to}${params}"')
     }


    Thursday, February 7, 2019 10:39 AM
  • 

    Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Thursday, February 21, 2019 6:52 AM