FrinkTheBrave
FrinkTheBrave

Reputation: 3958

How to Export and Import AD Users, Groups and Group Membership?

Hallo, I want to copy my Active Directory Users, Groups and Group Memberships from one DC to another using csvde, where the machines are identical except for the only the name of the Domain and Machine. Note that each server is a DC and itself is the only member of the domain. The command I am using for export is:

csvde -f C:\exportAD.csv -m -n -o "primaryGroupID,lockoutTime" -j C:\Logs\

I then edit the csv file, deleting a few lines which will not import, and changing the Domain and Machine name, then import it on the second machine using:

csvde -i -f C:\exportAD.csv -k -j C:\Logs\

However, this does not the group memberships present in the original.

Any ideas?

-Frink

Upvotes: 0

Views: 15591

Answers (2)

Mahmoud A. ATALLAH
Mahmoud A. ATALLAH

Reputation: 156

$Groups = Get-ADGroup -Filter * -SearchBase "DC=<DC Path>"
$Results = foreach( $Group in $Groups ){    
    Get-ADGroupMember -Identity $Group | foreach {    
        [pscustomobject]@{    
            GroupName = $Group.Name    
            Name = $_.Name    
            }    
        }    
    }    
$Results

Upvotes: 0

Related Questions