none
Mass Change of Owner to a folder and subfolders for %username% RRS feed

  • Question

  • Hi Script Gurus,

    I wondered how I would achieve this.?

    Background into why.

    Had 500 Users, wanted home folders. So used AD to select all users, and then properties and gave them a home drive in their profile by using the \\server\homedirs\%username%

    That then created 500 Folders called the username and gave the permissions for so Users had access

    Problem:

    It didn't make the User the owner of the folder, so redirected folders does not work in Group policy.

    Question:

    How can I run a script to make the user the owner of the folder and subfolders. Since all the folders are called the same name as the username I presume there is a way to permission it in a script.

    Plus Ideally at same time add a Group that can have read / write access to each folder and sub folder.

    Regards

    Richy

    • Moved by Bill_Stewart Tuesday, July 15, 2014 6:37 PM This is not "scripts on demand"
    Tuesday, May 13, 2014 7:28 PM

All replies

  • Settings owners with .NET / PowerShell code is sometimes a little flaky, so you may find that you need to fall back on something like takeown.exe.  However, here's the basic approach for the native PowerShell / .NET version:

    Get-ChildItem -Path \\server\homedirs -Directory | ForEach-Object { $directory = $_ $acl = $directory | Get-Acl $owner = [System.Security.Principal.NTAccount]"$env:USERDOMAIN\$($directory.Name)"

    $acl.SetOwner($owner) $acl | Set-Acl }


    Tuesday, May 13, 2014 7:52 PM
  • Hi Script Gurus,

    I wondered how I would achieve this.?

    Background into why.

    Had 500 Users, wanted home folders. So used AD to select all users, and then properties and gave them a home drive in their profile by using the \\server\homedirs\%username%

    That then created 500 Folders called the username and gave the permissions for so Users had access

    Problem:

    It didn't make the User the owner of the folder, so redirected folders does not work in Group policy.

    Question:

    How can I run a script to make the user the owner of the folder and subfolders. Since all the folders are called the same name as the username I presume there is a way to permission it in a script.

    Plus Ideally at same time add a Group that can have read / write access to each folder and sub folder.

    Regards

    Richy

    Delete al of the folders.  Create a redirection to a share.  Select to redirect all users to same location.  The folders will be created and the permisisons will be set correctly.

    We do not do this in script.  We have not done this with scripts since W2K GP was introduced.  Script is the NT 4 method of folder relocation.

    You also have the option to have the policy add the admin group to the security of the folder.  By default the folder is created with only SYSTEM and user access.


    ¯\_(ツ)_/¯

    Tuesday, May 13, 2014 9:27 PM