Export all AD Sites, Subnets, and SiteLinks and then import to different system

Hi,

Any suggestions on how to export all AD Sites, Subnets, and SiteLinks from a Server 2008 R2 Domain and then import and define to a Server 2012 R2 Domain?  I've seen isolated export and import scripts, but not an export and import script pair which works together.  Any help here would save me lots of time from manually def

August 28th, 2015 10:24pm

Have you looked inn the repository for examples.

This is not trivial. as it has to be done in layers.  Look into how to export the required elements of each item. 

Look into Export-Csv or Export-CliXml

Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 1:06am

Example:

# Export all sites
Get-ChildItem -path 'AD:\CN=Sites,CN=Configuration,DC=TESTNET,DC=local' -Filter '(objectclass=site)'| Export-CliXml Sites.clixml

#import and create site
$sites=Import-CliXml sites.clixml
$sites |%{New-Item -Path 'AD:\CN=Sites,CN=Configuration,DC=TESTNET,DC=local' -Name "CN=$($_.Name)" -ItemType Site }

August 29th, 2015 4:26am

Actually we can export everything in one swoop fell.

Get-ChildItem 'AD:\CN=Sites,CN=Configuration,DC=KAHLNET,DC=local' -recurse | Export-CliXml allsites.clixml

We cannot import the same way.  Each node has to be parsed and a New-Item call has to be constructed depending on the class of the node.

Import-CliXml allstes.clixml |
    ForEach-Object{
        switch ($_.objectclass){
            site {...}
            subnet {...}
            sitelink {....}
           ...etc
    }

Note that there are issues of order.  Almost all items are containers and need to be created in a hierarchy.  The objects in the export will be stored according to that hierarchy so walking the structure from top down would work.  There will need too be an  inspector step after the import that picks off the objects recursively.  The normal default enumeration will not do this.

Free Windows Admin Tool Kit Click here and download it now
August 29th, 2015 4:44am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics