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.