Clone local user groups and NTFS permissions from one computer to another

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Ondrej Zilinec Ondrej Zilinec 2 years, 1 month ago.

  • Author
    Posts
  • #20038
    Profile photo of Scott Bass
    Scott Bass
    Participant

    Hi,

    We're migrating from ServerA to ServerB. Are there Powershell scripts out there which can:

    1) Clone the local user groups from ServerA, and replicate them on ServerB?
    A) Assume domain membership in the local user groups – I can add in the local users manually.
    B) However, if I recreate the local users from ServerA on ServerB first, then if the script can add both the domain and local users (IOW an (u)exact (/u)copy with no manual intervention) then all the better.

    2) Clone the NTFS permissions from ServerA and replicate them on ServerB.
    Assume identical drive letters and directory names/paths between ServerA and ServerB.

    Apologies if this is a FAQ – I Googled extensively before posting, but I still haven't found what I'm looking for 🙂

    Regards,
    Scott

  • #20039
    Profile photo of Ondrej Zilinec
    Ondrej Zilinec
    Participant

    This is not a cookbook forum 🙂 Have you tried any powershell script to do what you want to do or just google it up?

    To find out all local groups use:

    $LocalMachineName = $env:computername
    Get-CimInstance -ClassName Win32_Group -filter "Domain = '$LocalMachineName'"
    

    To list all users from local groups use:

    $LocalMachineName = $env:computername
    $LocalGroupList = Get-CimInstance -ClassName Win32_Group -filter "Domain = '$LocalMachineName'"
    
    foreach($LocalGroup in $LocalGroupList)
    {
    $groupname = $LocalGroup.Name
    
    $group = [ADSI]"WinNT://./$groupname"
    ECHO "-----$($objLocalGroup.caption)-----"
    @($group.Invoke("Members")) | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
    }
    

    I think this is enought to have a list of users in local groups and add them into second server. If you want to replicate data with NTFS permissions I would use [b]robocopy.exe[/b].

    Have a nice day,

You must be logged in to reply to this topic.