Author Posts

October 23, 2014 at 8:17 pm

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

October 23, 2014 at 10:04 pm

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,