+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, Powershell (2012 R2) - Altering homeshare permissions in Coding and Web Development; I'm in the process of migrating to a new server, the existing setup didnt include individual permissions for each user. ...
  1. #1

    Join Date
    Feb 2007
    Location
    Leicestershire
    Posts
    260
    Thank Post
    1
    Thanked 5 Times in 5 Posts
    Rep Power
    27

    Powershell (2012 R2) - Altering homeshare permissions

    I'm in the process of migrating to a new server, the existing setup didnt include individual permissions for each user. I would like to add them to the new server. We have our users home folder named the same as the user and would like to do the following with each one.

    Add the user Read/Write/Modify to their own documents
    Enable inheritance for all below this folder
    Not to delete existing permissions.

    Instead of me starting from the begining does anyone have a powershell (2012 r2) script they use.

  2. #2


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,577
    Thank Post
    228
    Thanked 853 Times in 732 Posts
    Rep Power
    294
    easiest way ive found is to create the folder structure you want except the user folders then go to a bunch of users and change their homeshare to whatever you want so \\server\users$\staff\%username% and it will create all the folders with correct permissions then just drag and drop data back into users areas

  3. #3

    Join Date
    Feb 2007
    Location
    Leicestershire
    Posts
    260
    Thank Post
    1
    Thanked 5 Times in 5 Posts
    Rep Power
    27
    #----Config Area-------------------
    #Enter the Domain Name
    $domain = “domain”
    #Enter the root of the share
    $root = “F:\Documents\Students\08\”

    #----------------------------------
    $folders = Get-ChildItem $root

    ForEach ($folder in $folders)

    {
    #Create a var with the domain and username
    $username = $domain+“\”+$folder
    #Create a var with the full path the folder
    $fullfolderpath = $root+$folder
    #Get current acl of the folder
    $acl = Get-Acl $fullfolderpath
    #create a rule of permissions you would like to add
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule ($username, "DeleteSubdirectoriesAndFiles, Modify, Synchronize", "ContainerInherit, ObjectInherit", "None", "Allow")
    $acl.AddAccessRule($rule)
    #Add acl rule to path
    Set-Acl -Path $fullfolderpath -AclObject $acl
    }
    I've created a powershell to add the permissions, it's from the last hour of learning so may be rubbish. It doesn't contain any error handling either. It seems to add the correct permissions.

SHARE:
+ Post New Thread

Similar Threads

  1. System Center 2012 R2
    By Norphy in forum Enterprise Software
    Replies: 11
    Last Post: 19th February 2014, 04:55 PM
  2. Server 2012 R2 forum
    By gmonks in forum Comments and Suggestions
    Replies: 6
    Last Post: 24th October 2013, 12:55 PM
  3. Replies: 0
    Last Post: 16th October 2013, 06:55 PM
  4. Replies: 18
    Last Post: 4th October 2013, 03:13 PM
  5. 2012 R2 Preview out
    By DrCheese in forum Windows Server 2012
    Replies: 13
    Last Post: 25th June 2013, 04:41 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •