# Copyright (c) Microsoft Corporation. All rights reserved.
#
# THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK
# OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
#
# Synopsis: This script imports Edge config that has been previously exported using
# the export-edgeConfig script.
#
# Usage:
#
# Validate Phase: .\importedgeconfig
# -cloneConfigData "C:\cloneConfigData.xml"
# -cloneConfigAnswer "C:\cloneConfigAnswer.xml"
# -isImport $false
#
# Import Phase: .\importedgeconfig
# -cloneConfigData "C:\cloneConfigData.xml"
# -cloneConfigAnswer "C:\cloneConfigAnswer.xml"
# -isImport $true
# -Key:"A9ABA4D2C21C4bc58B303EA47BBE3608" (32 byte string used for
# password encryption/decryption)
#
param($cloneConfigData,
$cloneConfigAnswer,
$isImport = $false,
$key = "A9ABA4D2C21C4bc58B303EA47BBE3608")
$cloneTemplateDoc = new-object System.Xml.XmlDocument
$cloneDataDoc = new-object System.Xml.XmlDocument
$cloneAnswerDoc = new-object System.Xml.XmlDocument
#############################################################################
# Logs the information to the cloneLogFile.log
# isHost : If true Write the message to the host, inaddition to the log file.
# message : The message string to be logged.
#############################################################################
function Write-Information([Boolean] $isHost, [String] $message)
{
$logger.WriteLine();
$logger.WriteLine($message)
# Write the error message to the host also.
if($isHost -eq $true)
{
write-host $message
}
}
###########################################################################
# The function adds some useful information into the log file
# before the actual Export process starts.
###########################################################################
function Write-LogStartInformation()
{
$startTime = ([System.DateTime]::Now).ToString()
Write-Information $false "************ BEGIN IMPORT PROCESS **************"
Write-Information $false $startTime
}
#############################################################
# Releases the file handles used by the Export Script.
#############################################################
function Export-ReleaseHandles()
{
# Restore Error Action Preference
$ErrorActionPreference = $errorActionSave
write-debug "Export-ReleaseHandles"
if($logger -ne $null)
{
Write-Information $false "************ END IMPORT PROCESS **************"
$logger.flush()
$logger.close()
}
}
######################################################
# Retrieves the Root setup registry entry.
# returns: return entry value of found else null
######################################################
function GetEdgeInstallPath()
{
write-debug "GetEdgeInstallPath"
# Get the root setup entires.
$setupRegistryPath = "HKLM:\SOFTWARE\Microsoft\ExchangeServer\v14\Setup"
$setupEntries = get-itemproperty $setupRegistryPath
if($setupEntries -eq $null)
{
return $null
}
# Try to get the Install Path.
$installPath = $setupEntries.MsiInstallPath
return $installPath
}
######################################################
# Retrieves the Setup Regsitry value of the given entry.
# setupProperty: Setup Setting to the retrieved
# returns: return entry value of found else null
######################################################
function GetEdgeScriptsPath([String] $scriptFileName)
{
write-debug "GetEdgeScriptsPath"
# Append the script path with file name.
$scriptFilePath = $script:installPath + "Scripts\" + $scriptFileName
return $scriptFilePath
}
##################################################################################
# Creates a MultiValued string compatible with the Monad Multi value parameters.
# componentAnswerNodeItem: Multivalued node with child items.
# returns multivalued sting. ex: '0.0.0.0:25', '0.0.0.0:216'
##################################################################################
function createMultivaluedMonadString([System.Xml.XmlNode]$componentAnswerNodeItem)
{
write-debug ("CreateMultivaluedMonadString ")
$multiValuedString = $null
$individualMultivaluedNodes = $componentAnswerNodeItem.SelectNodes("Item")
write-debug ("individualNodes = $individualMultivaluedNodes")
if ($IndividualMultivaluedNodes)
{
# for each multivalued child node found.
foreach($individualMultivaluedNode in $individualMultivaluedNodes)
{
write-debug ("nodeValue=$nodeValue")
$nodeValue = $individualMultivaluedNode.Get_InnerXml().ToString().Trim()
if($nodeValue -ne "")
{
if($multiValuedString -eq $null)
{
$multiValuedString = "'" + $nodeValue + "'"
continue
}
$multiValuedString = $multiValuedString + ", '" + $nodeValue + "'"
}
}
}
return $multiValuedString
}
#######################################################################
# Validates the input parameters.
# Returns True if validation succeeds else False.
#######################################################################
function ValidateInput()
{
write-debug ("ValidateInput")
$isValid = $true
#check if the Configuration Data file exists.
$fileExists = [System.IO.File]::Exists($cloneConfigData)
if($fileExists -eq $false)
{
Write-Information $true "Cannot find Config Data file[$cloneConfigData]"
$isValid = $false
}
# if phase is Import and Answer File is passed as parameter.
# make sure the file exists.
if(($isImport -eq $true) -and ($cloneConfigAnswer -ne $null))
{
if([System.IO.File]::Exists($cloneConfigAnswer) -eq $false)
{
Write-Information $true "Cannot find Config Data file[$cloneConfigAnswer]"
$isValid = $false
}
}
if(($isImport -eq $false) -and ($cloneConfigAnswer -eq $null))
{
Write-Information $true "Please specify an Answer File Path."
$isValid = $false
}
return $isValid
}
#########################################################
# Validates the IP Address
# address: Address to be validated
#########################################################
function ValidateIPAddress([String] $address)
{
write-debug ("ValidateIPAddress " + $address)
[System.Net.IPAddress] $IpAddress = [System.Net.IPAddress]::Parse($address)
if($IpAddress -eq $null)
{
write-debug ("null IP Address")
return $false
}
# IPv4 or IPv6
if(($IpAddress.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetwork) -and
($IpAddress.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetworkV6))
{
write-debug ("not IPV4 or IPV6")
return $false
}
#IPANY, IPv6ANY, Loopback or a configured address
if(($IpAddress.Equals([System.Net.IPAddress]::Any) -eq $true) -or
($IpAddress.Equals([System.Net.IPAddress]::IPv6Any) -eq $true) -or
([System.Net.IPAddress]::IsLoopBack($IpAddress) -eq $true))
{
return $true
}
else
{
$flag = $false
$ipHostEntry = new-object System.Net.IPHostEntry
$ipHostEntry = [System.Net.Dns]::GetHostEntry([String]::Empty)
#Lookup the address in the hostlist
for($i = 0; $i -le $ipHostEntry.AddressList.Count; $i++)
{
if($IpAddress.Equals($ipHostEntry.AddressList[$i]) -eq $true)
{
$flag = $true
}
}
# bindingIP doesn't match any local IP Address
if($flag -eq $false)
{
write-debug ("bindingIP doesn't match any local IP Address")
return $false
}
}
trap
{
return $false
}
return $true
}
#######################################################################
# Validate the Bindings Multivalued parameter.
# Bindings: The string to be validated against a given Type.
# Returns NULL if all the entires succeded.
# Returns HashTable with validation entries for each item.
#######################################################################
function ValidateBindings([String] $bindings)
{
write-debug ("ValidateBindings " + $bindings)
$ValidBindingListHash = @{}
$validBindingsFlag = $true
# Example : '0.0.0.0:25', '214.0.0.0:25' #
# No need to check for Empty BindingsList.
$bindingsList = $bindings.Trim().Split(',')
foreach ($bindingsElement in $bindingsList)
{
# Split the IP:Port and validate the IPAddress Part.
$bindingsElement = $bindingsElement.Replace("'", "").Trim()
$items = $bindingsElement.Trim().Split(':')
if($items.Count -le 1)
{
$ValidBindingListHash[$bindingsElement] = $false
$validBindingsFlag = $false
continue
}
$a = ValidateIPAddress($items[0].ToString())
$ValidBindingListHash[$bindingsElement] = $a
if ($a -eq $false)
{
$validBindingsFlag = $false
}
}
if ($validBindingsFlag -eq $true)
{
return $null
}
return $ValidBindingListHash
}
#########################################################
# Validates the local Server FQDN
# address: Local Server FQDN to be validated
#########################################################
function ValidateFqdn([String] $fqdn)
{
write-debug ("ValidateFqdn " + $fqdn)
$localServerName = [System.Net.Dns]::GetHostName()
$localIPHostEntry = [System.Net.Dns]::GetHostEntry($localServerName)
$localServerFQDN = $localIPHostEntry.HostName
if ($fqdn -ine $localServerFQDN)
{
write-debug ("mismatched local Server FQDN")
return $false
}
trap
{
return $false
}
return $true
}
#######################################################################
# Validate whether a given Value matches to a given Type.
# Value: The string to be validated against a given Type.
# Type: The Validation Type.
# Returns True if validation succeeds else False.
# Returns false if the Type is "None"
#######################################################################
function ValidateItem([String] $value, [String] $type)
{
write-debug ("ValidateItem Value:$value Type:$type")
#Validation blocks for each Type.
#New blocks should be added for new Types.
$validItem = $true
if ($type -eq "DirectoryPath")
{
$validItem = [System.IO.Directory]::Exists($value.Trim())
write-debug "validItem=$validItem"
if($validItem -eq $false)
{
$dirInfo = [System.IO.Directory]::CreateDirectory($value.Trim())
$validItem = ($dirInfo -ne $null)
# remove any newly created directory
[System.IO.Directory]::Delete($value.Trim())
trap
{
write-debug ("trap: set validItem false")
$validItem = $false
}
}
}
elseif ($type -eq "NullableDirectoryPath")
{
if ($value -ne "")
{
$validItem = [System.IO.Directory]::Exists($value.Trim())
write-debug "validItem=$validItem"
if($validItem -eq $false)
{
$dirInfo = [System.IO.Directory]::CreateDirectory($value.Trim())
$validItem = ($dirInfo -ne $null)
# remove any newly created directory
[System.IO.Directory]::Delete($value.Trim())
trap
{
write-debug ("trap: set validItem false")
$validItem = $false
}
}
}
}
elseif ($type -eq "FilePath")
{
$FileFolder = [System.IO.Path]::GetDirectoryName($value.Trim())
$validItem = ValidateItem $FileFolder "DirectoryPath"
}
elseif($type -eq "IPAddress")
{
$validItem = ValidateIPAddress($value.Trim())
}
elseif($type -eq "Bindings")
{
# The return value is either NULL or
# an Hash table with atleast one elements.
# Multivalued property, we need to know the validation result
# of individual elements.
$validItem = ValidateBindings($value.Trim())
if ($validItem -eq $null)
{
write-debug ("valid bindings")
$validItem = $true
}
else
{
write-debug ("invalid bindings")
return $validItem
}
}
elseif($type -eq "FQDN")
{
# The return value is either NULL or
# an Hash table with atleast one elements.
# Multivalued property, we need to know the validation result
# of individual elements.
$validItem = ValidateFqdn($value.Trim())
if ($validItem -eq $null)
{
write-debug ("valid local server FQDN")
$validItem = $true
}
else
{
write-debug ("invalid local server FQDN")
return $validItem
}
}
else
{
# if you are here XML Template has validationType
# set to something that we are not supporting.
Write-Information $true "ValidationType [$type] is not supported."
}
write-debug ("return valid = $validItem")
return $validItem
}
###############################################################################
# Retrieve all the components of give component type from the data file.
# itterate through them to see if the machine specific information can be validated
# on the Target machine. if validation returns false add a keyed entry into the
# answer file.
# component: component type to retrieve from Data file.
# cloneDataDoc: XML Data file
# returns: String representation of the XML answer components.
###############################################################################
function ValidateAndAppendComponentConfig([System.Xml.XmlElement]$component,
[System.Xml.XmlDocument]$cloneDataDoc)
{
write-debug ""
write-debug ("ValidateAndAppendComponentConfig " + $component.ToString())
$componentPath = "/ExportedEdgeConfiguration/" + $component.ToString()
$componentDataNodes = $cloneDataDoc.SelectNodes($componentPath)
# If data nodes are present in the Data File
$appendString = ""
if($componentDataNodes)
{
#For each data node of this component Type
foreach($componentDataNode in $componentDataNodes)
{
$individualComponentString = ""
$componentItems = $component.Get_ChildNodes()
$componentDataNodeItems = $componentDataNode.Get_ChildNodes()
# if component has a key(meaning not unique, we have to add key to the
# to the answer file node.
if($component.GetAttribute("Key") -ne "None")
{
$individualComponentString = $individualComponentString +
"<" + $component.ToString() +
" " + $component.GetAttribute("Key") +
"='" + $componentDataNode.Get_Item($component.GetAttribute("Key")).Get_InnerXml() +
"'"+ ">"
}
# if the component doen't have a Key(always will be a single node, on both source
# and target server
else
{
$individualComponentString = $individualComponentString + "<" +
$component.ToString() + ">"
}
write-debug ("IndividualComponentString $individualComponentString `n")
write-debug ""
# for each machine specific item in this Data Node
$machineSpecificAnswerString = ""
foreach($componentItem in $componentItems)
{
#Get the validation Type Key
$validationType = $componentItem.GetAttribute("ValidationType")
write-debug ("Validate " + $componentItem.Get_InnerText() + " element of type $validationType" )
#validate the machine specific item on the target server.
$isValid = ValidateItem $componentDataNode.Get_Item($componentItem.Get_InnerText()).Get_InnerXml() $validationType
#if the validation failed add entry in the answer file
# for admin to enter it manually.
if ($isValid -eq $false)
{
Write-Information $true ("Validation Failed for " + $componentItem.Get_InnerText() +
" element of type " + $validationType)
$machineSpecificAnswerString = $machineSpecificAnswerString +
""
$machineSpecificAnswerString = $machineSpecificAnswerString +
"<" + $componentItem.Get_InnerText() + ">" +
$componentDataNode.Get_Item($componentItem.Get_InnerText()).Get_InnerXml() +
"" + $componentItem.Get_InnerText() + ">"
}
# if the validation succeeded Add an entry to the console.
elseif ($isValid -eq $true)
{
Write-Information $true ("Validation succeeded for " + $componentItem.Get_InnerText() +
" element of type $validationType" )
}
else
{
# if we are here we got a hash table with validation status of each item
# of a multivalued property.
Write-Information $true ("Validation Failed for " + $componentItem.Get_InnerText() +
" Multivalued element of type $validationType : Answer file entry created" )
$machineSpecificAnswerString = $machineSpecificAnswerString +
"<" + $componentItem.Get_InnerText() + ">"
foreach($hashKey in $isValid.Get_Keys())
{
if ($isValid[$hashKey] -eq $false)
{
$machineSpecificAnswerString = $machineSpecificAnswerString +
""
}
else
{
$machineSpecificAnswerString = $machineSpecificAnswerString +
""
}
$machineSpecificAnswerString = $machineSpecificAnswerString +
"- " +
$hashKey +
"
"
}
$machineSpecificAnswerString = $machineSpecificAnswerString +
"" + $componentItem.Get_InnerText() + ">"
}
}
write-debug ("machineSpecificAnswerString $machineSpecificAnswerString")
if ($machineSpecificAnswerString -ne "")
{
$appendString = $appendString + $individualComponentString
$appendString = $appendString + $machineSpecificAnswerString
$appendString = $appendString + "" + $component.ToString() + ">"
}
}
}
return $appendString
}
##############################################################################
# This function does the extra processing work, which is required for some
# parameters outputted by the Monad Tasks.
# DataComponent: The data node from which we will populate
# the values for the task parameters.
# Returns: The command string if any else null.
##############################################################################
function CreateExtraProcessingCommand([System.Xml.XmlElement]$datacomponent)
{
$extraCommandString = $null
# As of now SendConnector is the only object we have to do extra processing.
# Only for the LinkedReceiveConnector parameter.
if($datacomponent.ToString().ToUpper() -eq "SENDCONNECTOR")
{
write-debug ("CreateExtraProcessingCommand " + $dataComponent.ToString())
$linkedReceiveConnector = $datacomponent.Get_Item("LinkedReceiveConnector").Get_InnerXml().Trim()
if($linkedReceiveConnector -ne '$null')
{
$extraCommandString = "Set-SendConnector -Identity '" +
$datacomponent.Get_Item("Name").Get_InnerXml().Trim() +
"'"
$linkedReceiveConnectorItems = $linkedReceiveConnector.Trim().Split(',')
$linkedReceiveConnectorObject = get-receiveconnector $linkedReceiveConnectorItems[0]
if($linkedReceiveConnectorObject -ne $null)
{
$extraCommandString = $extraCommandString +
" -LinkedReceiveConnector '" +
$linkedReceiveConnectorObject.Identity +
"'"
}
}
}
return $extraCommandString
}
##########################################################################################
# Create each individual monad task command to be run on the Target Server.
# command: The command name, its also used to get the parameters this command takes.
# Datacomponent: The data node from which we will populate the values for the task parameters.
# AnswerComponent: The answer node from which we will populate the machine related task paramaters.
# NonClonableItemsNode: Skip the task parameters which are listed in this Node.
# Key: There are some commands whose identity or server info cannot be cloned and they are single
# Objects on Edge, in these cases use pipelining to set the Object
##########################################################################################
function EvaluateAndAppendCommandParameters([String]$command,
[System.Xml.XmlElement]$datacomponent,
[System.Xml.XmlElement]$answerComponent,
[System.Xml.XmlElement]$NonClonableItemsNode,
[String]$key,
[String]$preConditionVerb)
{
write-debug ("EvaluateAndAppendCommandParameters " + $command)
write-debug ("preconditionVerb=" + $preConditionVerb)
$commandWithParameters = ""
$cmdObject = get-command $command
$commandWithParameters = $command
# for each parameter of this object
foreach($parameter in $cmdObject.ParameterSets[0].Parameters)
{
write-debug ("parameter= " + $parameter.Name)
# For each parameter the resulting command can take;
# If the parameter is in the non-clonable list just ignore it
# Else Try to get the value from the Answer file if any.
# Else use the value present in the data file.
if($NonClonableItemsNode)
{
$nonClonableItems = $NonClonableItemsNode.Item
$nonCloneFlag = $false
# if this parameter is a no clonnable item,
# ignore this parameter in resulting task command.
foreach($nonClonableItem in $nonClonableItems)
{
if($nonClonableItem.Trim() -eq $parameter.Name)
{
$nonCloneFlag = $true
break;
}
}
if($nonCloneFlag -eq $true)
{
continue;
}
}
# if Data for this parameter is present in the Answer file pick it
# else use the data from the Data file.
# we don't need to check for "" and "{}" since the intial validation
# while importing will fail if they are empty.
if(($answerComponent) -and
($answerComponent.Get_Item($parameter.Name)) -and
($answerComponent.Get_Item($parameter.Name).Get_InnerXml() -ne "") -and
($answerComponent.Get_Item($parameter.Name).Get_InnerXml() -ne "{}"))
{
# if Multivalued Answer Node create the command string from the
# child nodes.
if ($answerComponent.Get_Item($parameter.Name).Get_ChildNodes().Count -gt 1)
{
$multiValuedString = createMultivaluedMonadString($answerComponent.Get_Item($parameter.Name))
$paramString = " -" +
$parameter.Name + ":" +
$multiValuedString
$commandWithParameters = $commandWithParameters + $paramString
}
# if boolean use $true or $false. Based on its value in the answer file
elseif($parameter.ParameterType.Name -eq "Boolean")
{
$commandWithParameters = $commandWithParameters + " -" +
$parameter.Name + ":$" +
$answerComponent.Get_Item($parameter.Name).Get_InnerXml().ToLower()
}
# if not boolean consider as a regular string, tasks will take care of
# converting them to specific Type ( TimeStamp, IpAddress etc..)
else
{
$escapedValue = $answerComponent.Get_Item($parameter.Name).Get_InnerXml().Trim()
$escapedValue = $escapedValue.Replace(">",">")
$escapedValue = $escapedValue.Replace("<","<")
$commandWithParameters = $commandWithParameters + " -" +
$parameter.Name + " '" +
$escapedValue + "'"
}
}
# if not present in the answer file, pick them from the data file only
# if the parameter is there
elseif ($datacomponent.Get_Item($parameter.Name) -ne $null)
{
write-debug ("parameter elt present= " + $parameter.Name)
# if it is not blank OR the precondition is "SetBlank".
if (($datacomponent.Get_Item($parameter.Name).Get_InnerXml() -ne "") -or
($preConditionVerb -eq "SetBlank"))
{
write-debug ("parameter not blank OR no Remove precondition")
# pass null to the corresponding element during import phase.
if($datacomponent.Get_Item($parameter.Name).Get_InnerXml() -eq '$null')
{
$commandWithParameters = $commandWithParameters + " -" +
$parameter.Name + ":$" + "null"
}
# if the parameter is of type MultiValued construct the command
# accordingly.
elseif($parameter.ParameterType.Name.ToString().ToUpper().StartsWith("MULTIVALUED"))
{
$paramString = " -" +
$parameter.Name + ":" +
$datacomponent.Get_Item($parameter.Name).Get_InnerXml().Trim()
$commandWithParameters = $commandWithParameters + $paramString
}
# if boolean use $true or $false. Based on its value in the Data node.
elseif($parameter.ParameterType.Name -eq "Boolean")
{
$commandWithParameters = $commandWithParameters + " -" +
$parameter.Name + ":$" +
$datacomponent.Get_Item($parameter.Name).Get_InnerXml().ToLower()
}
# if PSCredential construct a new credential object
elseif($parameter.ParameterType.Name -eq "PSCredential")
{
$mshCredentialNode = $datacomponent.Get_Item($parameter.Name)
$userName = $mshCredentialNode.Get_Item("UserName").Get_InnerXml()
$encryptedPassword = $mshCredentialNode.Get_Item("Password").Get_InnerXml()
$securePassword = ConvertTo-SecureString -String $encryptedPassword -key $encryptionKey
# $encryptedPassword = ConvertFrom-SecureString -SecureString $securePassword -key $encryptionKey
# Catch password conversion errors
if ($securePassword -eq $null)
{
throw $Error[0].Exception
}
$script:Credential = new-object System.Management.Automation.PSCredential ($userName, $securePassword)
write-debug ("credential.UserName=" + $Credential.UserName)
# write-debug ("credential.Password=" + $Credential.GetNetworkCredential().Password)
$paramString = " -" +
$parameter.Name + ":" + '$script:Credential'
$commandWithParameters = $commandWithParameters + $paramString
}
elseif ($parameter.Name -eq "ProxyServerType")
{
$stringProxyServerType = $datacomponent.Get_Item($parameter.Name).Get_InnerXml().ToLower()
write-debug ("stringProxyServerType = " + $stringProxyServerType)
$paramString = " -" +
$parameter.Name + ":" + $stringProxyServerType
$commandWithParameters = $commandWithParameters + $paramString
}
# Otherwise consider as a regular string, tasks will take care of
# converting them to specific Type ( TimeStamp, IpAddress etc..)
else
{
$escapedValue = $datacomponent.Get_Item($parameter.Name).Get_InnerXml().Trim()
$escapedValue = $escapedValue.Replace(">",">")
$escapedValue = $escapedValue.Replace("<","<")
$commandWithParameters = $commandWithParameters + " -" +
$parameter.Name + " '" +
$escapedValue + "'"
}
}
}
}
# If this command has machine specific information and the component
# associated with this is unique. ex-- TransportServer.
if(($key) -and ($key -eq "None"))
{
$MachineName = [System.Environment]::MachineName
$commandWithParameters = "Get-" + $datacomponent.ToString() + " -Identity:" +
$MachineName + " | " +
$commandWithParameters
#write-debug ("Unique/Machine specific completeCommand= " + $commandWithParameters)
}
Write-Information $false $commandWithParameters
write-debug ("commandWithParameters= " + $commandWithParameters)
return $commandWithParameters
}
##########################################################################################
# Creates and runs commands
# ImportTemplateComponent: Encapsulates the Type of component and
# commands to be run on the Target machine.
# Datacomponent: Data File Node
# AnswerComponent: Machine Specific Data Node
# Key: Key which Distinguishes objects of same component Type.
##########################################################################################
function ImportObject([System.Xml.XmlElement]$importTemplateComponent,
[System.Xml.XmlElement]$datacomponent,
[System.Xml.XmlElement]$answerComponent,
[String]$key)
{
write-debug ""
write-debug ("ImportObject " + $importTemplateComponent.ToString())
$preConditionVerb = $importTemplateComponent.GetAttribute("PreCondition").ToString()
write-debug ("Precondition = " + $preconditionVerb)
# Creates the Monad Command
# As of now the PreCondition and PostCOndition have only single command.
# ImportVerbs may have multiple elements so split them and build each command seperately.
$command = ""
$baseCommand = ""
if(($importTemplateComponent.GetAttribute("ImportVerbs").ToString()) -ne "None")
{
# In some cases output from a single task may have to be
# sent to multiple tasks with the same Noun.
# In these cases ImportVerbs will have multiple items separated by :
$subCmds = $importTemplateComponent.GetAttribute("ImportVerbs").ToString().Split(':')
write-debug ("ImportVerbs:" + $importTemplateComponent.GetAttribute("ImportVerbs").ToString())
foreach($subCmd in $subCmds)
{
# Special Case specific to TransportAgents
# There are two different tasks to enable/disable(why?).
if($subCmd -eq "EnableOrDisable")
{
#Assuming that the parameter name associated with flag is "Enabled"
#Will have to add some extra mappings in Template XML to care of this.
if($datacomponent.Get_Item("Enabled").Get_InnerXml().ToString() -eq "True")
{
$baseCommand = "Enable-" + $importTemplateComponent.ToString()
}
else
{
$baseCommand = "Disable-" + $importTemplateComponent.ToString()
}
}
else
{
# command created from ImportVerbs element and component name which is Noun.
$baseCommand = $subCmd + "-" + $importTemplateComponent.ToString()
}
# Now we have command name, So go get the parameters and append to command.
$nonclonableItemsNode = $importTemplateComponent.Get_Item("NonClonableItems")
$completeCommand = EvaluateAndAppendCommandParameters $baseCommand $datacomponent $answerComponent $nonClonableItemsNode $key $preConditionVerb
write-debug ("importTemplateComponent = " + $importTemplateComponent.ToString())
# Special Case specific to RemoteDomain to deal with Identity and unremovable Default instance
if ($importTemplateComponent.ToString() -eq "RemoteDomain")
{
$domainName = $datacomponent.Get_Item("DomainName").Get_InnerXml().ToString()
write-debug "domainName=$domainName"
#We can't do a New on the (fixed) Default RemoteDomain Value since it can't be removed initially
if ($subCmd -eq "New")
{
if ($domainName -eq "*")
{
# Special handling for Default Remote Domain
# We can't do a New on the Default RemoteDomain Value since it can't be removed initially
# However if it doesn't exist we have to create it
$remoteDomain = get-remotedomain | where {$_.DomainName -eq $domainName}
if ($remoteDomain -ne $null)
{
write-debug "Continue for Default New-RemoteDomain"
continue
}
}
}
else
{
# Save the New-RemoteDomain Identity param for the Set-RemoteDomain
$remoteDomain = get-remotedomain | where {$_.DomainName -eq $domainName}
write-debug ("Identity=" + $remoteDomain.Identity.Name.ToString())
$completeCommand = $completeCommand + " -Identity:" + "'" + $remoteDomain.Identity.Name + "'"
}
}
# Special Case specific to AcceptedDomain to deal with Identity
if ($importTemplateComponent.ToString() -eq "AcceptedDomain")
{
$domainName = $datacomponent.Get_Item("DomainName").Get_InnerXml().ToString()
write-debug "domainName=$domainName"
$name = $datacomponent.Get_Item("Name").Get_InnerXml().ToString()
write-debug "Name=$name"
#We can't do a New on the (fixed) Default RemoteDomain Value since it can't be removed initially
if ($subCmd -eq "Set")
{
# Save the New-AcceptedDomain Identity param for the Set-AcceptedDomain
$acceptedDomain = get-accepteddomain | where {$_.Name -eq $name}
write-debug ("Identity=" + $acceptedDomain.Identity.Name.ToString())
$completeCommand = $completeCommand + " -Identity:" + "'" + $acceptedDomain.Identity.Name + "'"
# If this was the Original Default Accepted Domain make it the new Default
write-debug ("defaultDomain?:" + $datacomponent.Get_Item("Default").Get_InnerXml())
if ($datacomponent.Get_Item("Default").Get_InnerXml() -eq $true)
{
write-debug ("Original Default AcceptedDomain")
$completeCommand = $completeCommand + ' -MakeDefault:$true'
}
}
}
write-debug ("invoke-expression " + $completeCommand)
# invoke the command with parameters.
invoke-expression $completeCommand
$command = $command + $baseCommand
}
# This is to take care of some parameters that cannot be handled
# in a generic way. EvaluateAndAppendCommandParameters only looks at the first parameter set
# For SendConnectors the LinkedReceiveConnector parameter is in the second parameter set and so
# this needs to be handled as a special case.
$extraCommand = CreateExtraProcessingCommand $datacomponent
# write-debug ("extraCommand= " + $extraCommand)
if($extraCommand -ne $null)
{
Write-Information $false $extraCommand
invoke-expression $extraCommand
$command = $command + $extraCommand
}
}
return $command
}
##########################################################################################
# Imports the configuration using clone Template, Data File and Answer File.
# cloneTemplateDoc: Clone Template document.
# cloneDataDoc: Data document.
# cloneAnswerDoc: Answer file document.
##########################################################################################
function ImportConfig([System.Xml.XmlDocument]$cloneTemplateDoc,
[System.Xml.XmlDocument]$cloneDataDoc,
[System.Xml.XmlDocument]$cloneAnswerDoc)
{
write-debug ("ImportConfig ")
$importSpecificRoot = $cloneTemplateDoc.SelectSingleNode("/cloneTemplate/importCloneItems")
# Get all the import items.
$importItems = $importSpecificRoot.Get_ChildNodes()
# Get all machine specific items.
$machineSpecificRoot = $cloneTemplateDoc.SelectSingleNode("/cloneTemplate/machineSpecificItems")
# For each import specific item.
foreach($importItem in $importItems)
{
$componentDataPath = "/ExportedEdgeConfiguration/" + $importItem.ToString()
$AnswerDataPath = "/MachineSpecificSettings/" + $importItem.ToString()
# Get the machine specific node if any for this import item.
$machineSpecificComponentItem = $machineSpecificRoot.Get_Item($importItem.ToString())
# Get the Data nodes if any for this import item.
$componentSpecificDataNodes = $cloneDataDoc.SelectNodes($componentDataPath)
# Get the Answer file node if any for this import item.
$componentSpecificAnswerNodes = $cloneAnswerDoc.SelectNodes($AnswerDataPath)
write-debug ""
write-debug ("importItem= " + $importItem.ToString())
write-debug ("componentSpecificDataNodes= $componentSpecificDataNodes")
write-debug ("componentSpecificAnswerNodes= $componentSpecificAnswerNodes")
$key = $null
if($machineSpecificComponentItem)
{
# Get the key if any for this import item from machine specfic Node.
$key = $machineSpecificComponentItem.GetAttribute("Key")
}
$preConditionVerb = $importItem.GetAttribute("PreCondition").ToString()
$componentNoun = $importItem.ToString()
write-debug ("key= $key")
write-debug ("PreconditionVerb = " + $preConditionVerb)
#As of now precondition can be either "None", "SetBlank" or "Remove"
#If "Remove" Remove all the components of the current Type before adding new ones.
#Better way of doing is put all the cleanup process as a separate block in the Template
if( $preConditionVerb -eq "Remove")
{
# Clean up all the items of this Type on the Target machine.
# I prefered to do it here so that we can delete all the objects in a single command
# by using Monad pipelining
if ($componentNoun -eq "IPAllowListEntry")
{
$baseCommand = $preConditionVerb + "-" + $componentNoun
$cleanupCommand = 'Get-IPAllowListEntry | where { $_.IsMachineGenerated -eq $false}' + " | " + $baseCommand
write-debug ("cleanupCommand= $cleanupCommand")
invoke-expression $cleanupCommand
}
elseif ($componentNoun -eq "RemoteDomain")
{
$baseCommand = $preConditionVerb + "-" + $componentNoun
$cleanupCommand = 'Get-RemoteDomain | where { $_.DomainName -ne "*"}' + " | " + $baseCommand
write-debug ("cleanupCommand= $cleanupCommand")
invoke-expression $cleanupCommand
}
elseif ($componentNoun -eq "AcceptedDomain")
{
# If no accepteddomains exist then don't add the unique one.
$existingDomains = Get-AcceptedDomain
if ($existingDomains -ne $null)
{
# Add a Unique GUID Value and make it the new Default
$cleanupCommand = 'New-AcceptedDomain '
$cleanupCommand = $cleanupCommand + ' -DomainName:' + $script:uniqueName
$cleanupCommand = $cleanupCommand + ' -Name:' + $script:uniqueName
write-debug ("cleanupCommand= $cleanupCommand")
invoke-expression $cleanupCommand
$cleanupCommand = 'Set-AcceptedDomain -Identity:' + $script:uniqueName + ' -MakeDefault:$true'
write-debug ("cleanupCommand= $cleanupCommand")
invoke-expression $cleanupCommand
$baseCommand = $preConditionVerb + "-" + $componentNoun
$cleanupCommand = 'Get-AcceptedDomain | where { $_.Default -ne $true}' + " | " + $baseCommand
write-debug ("cleanupCommand= $cleanupCommand")
invoke-expression $cleanupCommand
}
}
else
{
$baseCommand = $preConditionVerb + "-" + $componentNoun
$cleanupCommand = "Get-" + $componentNoun + " | " + $baseCommand
write-debug ("cleanupCommand= $cleanupCommand")
invoke-expression $cleanupCommand
}
}
$cmd = ""
# Get the data nodes for each import specific item.
# and import the data
foreach($componentSpecificDataNode in $componentSpecificDataNodes)
{
[Boolean]$foundMatchingAnswerNode = $false
# find a matching Answer node if any.
foreach($componentSpecificAnswerNode in $componentSpecificAnswerNodes)
{
# if the key is "None", unique node so just pass whatever you have in hand and break.
if($key -eq "None")
{
$foundMatchingAnswerNode = $true
write-debug ("found matching answer node for unique data node")
$cmd = ImportObject $importItem $componentSpecificDataNode $componentSpecificAnswerNode $key
break
}
# find a matching key node in the answer file for the component and use that Answer Node.
elseif(($componentSpecificAnswerNode.GetAttribute($key)) -eq
($componentSpecificDataNode.Get_Item($key).Get_InnerXml()))
{
write-debug ("found matching answer node for multi data node")
$foundMatchingAnswerNode = $true
$cmd = ImportObject $importItem $componentSpecificDataNode $componentSpecificAnswerNode $key
break;
}
}
# If there is no answer node(meaning doesn't contain any machine specific information
# for this item) just use the Data Node.
if($foundMatchingAnswerNode -eq $false)
{
write-debug ("no machine specific answer node - use exported data node directly")
$cmd = ImportObject $importItem $componentSpecificDataNode $null $key
}
}
#As of now postcondition can be either "None" or "Remove"
#If "Remove" then Remove the temporary Unique Default value used to handle non-removeble defaults
$postConditionVerb = $importItem.GetAttribute("PostCondition").ToString()
$componentNoun = $importItem.ToString()
write-debug ("PostConditionVerb = " + $postConditionVerb)
if( $postConditionVerb -eq "Remove")
{
#As of now only AcceptedDomain has a postcondition
if ($componentNoun -eq "AcceptedDomain")
{
$postConditionCommand = 'Get-AcceptedDomain | where {$_.DomainName -eq "' + $script:uniqueName + '"} | Remove-AcceptedDomain '
write-debug ("postConditionCommand= $postConditionCommand")
invoke-expression $postConditionCommand
}
}
}
}
##########################################################################################
# Creates the Answer File.
# cloneTemplateDoc: Clone Template document.
# cloneDataDoc: Data document.
# cloneConfigAnswer: Name of the answer file including complete path.
##########################################################################################
function ValidateAndCreateAnswerFile([System.Xml.XmlDocument]$cloneTemplateDoc,
[System.Xml.XmlDocument]$cloneDataDoc,
[String]$cloneConfigAnswer)
{
write-debug "ValidateAndCreateAnswerFile "
$rootNode = "MachineSpecificSettings"
$xmlData = "<" + $rootNode + ">"
$machineSpecificNode = $cloneTemplateDoc.SelectSingleNode("/cloneTemplate/machineSpecificItems")
# Get all the machine specific nodes.
$components = $machineSpecificNode.Get_ChildNodes()
# for each machine specific node
foreach($component in $components)
{
# Validate the machine specific info on the Target machine and
# Get all the non valid nodes.
$xmlItem = ValidateAndAppendComponentConfig $component $cloneDataDoc
$xmlData = $xmlData + $xmlItem
}
# There should not be any string overflow because there is very little data
# in the Answer file.
$xmlData = $xmlData + "" + $rootNode + ">"
$xmlDocument = [System.Xml.XmlDocument]($xmlData)
$xmlDocument.Save($cloneConfigAnswer)
}
##########################################################################################
# Validates the Answer File.
# cloneTemplateDoc: Clone Template document.
# cloneDataDoc: Data document.
# Returns True if success else False
##########################################################################################
function ValidateAnswerFile([System.Xml.XmlDocument]$cloneTemplateDoc,
[System.Xml.XmlDocument]$cloneAnswerDoc)
{
write-debug "ValidateAnswerFile"
write-verbose "ValidateAnswerFile"
$isValid = $true
$machineSpecificNode = $cloneTemplateDoc.SelectSingleNode("/cloneTemplate/machineSpecificItems")
write-debug ("machineSpecificNode= " + $machineSpecificNode)
# Get Machine specific componenets
$components = $machineSpecificNode.Get_ChildNodes()
# for each machine specific component.
foreach($component in $components)
{
write-debug ("TemplateComponent = " + $component.ToString())
$componentItems = $component.Get_ChildNodes()
$componentPath = "/MachineSpecificSettings/" + $component.ToString()
# Get all the components for this machine specific component.
$componentAnswerNodes = $cloneAnswerDoc.SelectNodes($componentPath)
if($componentAnswerNodes)
{
# For each answer component
foreach($componentAnswerNode in $componentAnswerNodes)
{
write-debug ("AnswerFileComponent = " + $componentAnswerNode.ToString())
# Get each individual item in this Answer component node
$componentAnswerNodeItems = $componentAnswerNode.Get_ChildNodes()
if($componentAnswerNodeItems)
{
# Do process for each item in this answer node.
# for MultiValuedProperty node we will have child nodes
# which have to be taken in consideration.
foreach($componentAnswerNodeItem in $componentAnswerNodeItems)
{
write-debug ("AnswerNodeItem=" + $componentAnswerNodeItem.ToString())
#Loop through the machine items to find a match
# for this answer item
foreach($componentItem in $componentItems)
{
write-debug ("TemplateNodeItem=" + $componentItem.Get_InnerXml().ToString())
# if match is found
if($componentItem.Get_InnerXml().ToString() -eq $componentAnswerNodeItem.ToString())
{
write-debug ("MATCH:TemplateNode=AnswerNode")
# if Multivalued property Validation
if ($componentAnswerNodeItem.Get_ChildNodes().Count -gt 1)
{
$currentAnswerNodeValue = createMultivaluedMonadString($componentAnswerNodeItem)
}
else
{
$currentAnswerNodeValue = $componentAnswerNodeItem.Get_InnerXml().ToString().Trim()
}
write-debug ("AnswerNodeValue=$currentAnswerNodeValue")
#if data not found for this item in the answer node validation failed.
if ($currentAnswerNodeValue -eq "")
{
Write-Information $true "Validation Failed: " $component.ToString() $componentItem.Get_InnerXml().ToString() "{" $currentAnswerNodeValue "}"
$isValid = $false
break
}
# if match found and not empty and validation Type is "None"
# skip this item.
elseif ($componentItem.GetAttribute("ValidationType") -eq "None")
{
break
}
#if validation Type is not "None" do validation.
$temp = ValidateItem $currentAnswerNodeValue $componentItem.GetAttribute("ValidationType")
# if validation failed Log the failure.
if ($temp -eq $false)
{
Write-Information $true "Validation Failed: " $component.ToString() $componentItem.Get_InnerXml().ToString() "{" $currentAnswerNodeValue $componentItem.GetAttribute("ValidationType") "}"
$isValid = $false
}
elseif ($temp -eq $true)
{
}
else
{
$isValid = $false
foreach($hashKey in $temp.Get_Keys())
{
if ($temp[$hashKey] -eq $false)
{
Write-Information $true "Validation Failed: " $component.ToString() $componentItem.Get_InnerXml().ToString() "{" $hashKey $componentItem.GetAttribute("ValidationType") "}"
}
}
}
write-debug ""
break
}
}
}
}
}
}
}
return $isValid
}
#############################################################################
# InitializationCheck
# Setup script variables, check arguments etc.
#############################################################################
function InitializationCheck()
{
write-debug "InitializationCheck"
# Global variable for storing handle to the clone log file.
# Change this to Actual Path relative to [C:\Program Files\Microsoft\Exchange Server\]
$script:success = $false
$script:uniqueName = "A9ABA4D2-C21C-4bc5-8B30-3EA47BBE3608"
$script:uniqueKey = "A9ABA4D2C21C4bc58B303EA47BBE3608"
$script:installPath = GetEdgeInstallPath
$script:logfilePath = $installPath + "Logging\SetupLogs\cloneLogFile.log"
$script:logger = new-object System.IO.StreamWriter ($logfilePath , $true)
if ($key -eq $uniqueKey)
{
write-host -ForegroundColor "red" "Warning:Passwords will be encrypted with the default script encryption key"
}
# Check/Setup the SecurePassword encryption key
if (($key.Length -ne 32) -and
($key.Length -ne 24) -and
($key.Length -ne 16))
{
Write-Information $true "Key Length needs to be 16, 24 or 32 bytes long."
return
}
$script:encryptionKey = $key.ToCharArray()
write-debug ("encryption key=" + $encryptionKey)
Write-LogStartInformation
# Return error if any extra parameters are supplied.
if($script:args.Count -gt 0)
{
foreach($arg in $script:args)
{
Write-Information $true "Invalid additional parameter $arg passed."
}
return
}
# Adam Service Name
$AdamServiceName = "ADAM_MSExchange"
# Make sure ADAM_MsExchange Service is running.
$adamServiceStatus = get-service $AdamServiceName
if(($adamServiceStatus -eq $null) -or
($adamServiceStatus.Status -ne [System.ServiceProcess.ServiceControllerStatus]::Running))
{
Write-Information $true "Adam service should be running, in order to import clone config."
return
}
# Initialize "global" variables that can be used in the template.
$script:MachineName = [System.Environment]::MachineName
$script:edgeServer = get-ExchangeServer -Identity:$MachineName | where { $_.IsEdgeServer -eq $true }
if (!$script:edgeServer)
{
Write-Information $true "Please run the Import script on the Edge Server."
return
}
$isValidInput = validateInput
if($isValidInput -eq $false)
{
return
}
$script:success = $true
}
$cloneTemplate =
'
- ConnectivityLogPath
- MessageTrackingLogPath
- PickupDirectoryPath
- PipelineTracingPath
- ReceiveProtocolLogPath
- ReplayDirectoryPath
- RoutingTableLogPath
- RootDropDirectoryPath
- SendProtocolLogPath
- SourceIPAddress
- Bindings
- Fqdn
- Identity
- PickupDirectoryDefaultDomain
- ExternalDsnReportingAuthority
- InternalDsnReportingAuthority
- ExternalPostmasterAddress
- Name
- Identity
- Identity
- CharacterSet
- NonMimeCharacterSet
- ContentType
- LineWrapSize
- MsExchRoutingDisplaySenderEnabled
- TNEFEnabled
- AllowedOOFType
- AutoReplyEnabled
- AutoForwardEnabled
- DeliveryReportEnabled
- NDREnabled
- MeetingForwardNotificationEnabled
- Server
- AdvertisedDomain
- PermissionGroups
- Identity
'
#######################################################################
# Main Script starts here. Validates the parameters and based on isImport value
# will run through the Import or Create answer file Steps.
#######################################################################
$errorActionSave = $ErrorActionPreference
# Do all the Initialization Checks
InitializationCheck
if (-not $success)
{
Export-ReleaseHandles
exit
}
write-debug "Main"
write-debug ("cloneConfigData = $cloneConfigData")
$cloneTemplateDoc.LoadXML($cloneTemplate)
$cloneDataDoc.Load($cloneConfigData)
if($isImport -eq $true)
{
# Incase of Importing.
write-verbose "Import Cloned Config"
if($cloneConfigAnswer -ne $null)
{
$cloneAnswerDoc.Load($cloneConfigAnswer)
trap
{
Write-Information $true "Loading Answer File Failed."
Write-Information $true ("Reason: " + $error[0])
Export-ReleaseHandles
exit
}
}
# Incase of Restoring.
else
{
$emptyAnswerString = ""
$cloneAnswerDoc = [System.Xml.XmlDocument]($emptyAnswerString)
}
$validationSuccess = ValidateAnswerFile $cloneTemplateDoc $cloneAnswerDoc
if($validationSuccess -eq $false)
{
Write-Information $true ("Validation Process Failed. Please enter correct information in " + $cloneConfigAnswer)
Export-ReleaseHandles
exit
}
ImportConfig $cloneTemplateDoc $cloneDataDoc $cloneAnswerDoc
trap
{
# Catch password conversion errors
if ($error[0].Exception.GetType() -eq [System.Security.Cryptography.CryptographicException])
{
Write-Information $true "Password Decryption Failed - Check the decryption key."
}
else
{
Write-Information $true "Importing Edge configuration information Failed."
}
Write-Information $true ("Reason: " + $error[0])
Export-ReleaseHandles
exit
}
Write-Information $true "Importing Edge configuration information Succeeded."
}
else
{
write-verbose "Validate Cloned Config"
# Don't display errors For Validation Phase
$ErrorActionPreference = "SilentlyContinue"
ValidateAndCreateAnswerFile $cloneTemplateDoc $cloneDataDoc $cloneConfigAnswer
trap
{
# Restore Error Action Preference
$ErrorActionPreference = $errorActionSave
Write-Information $true "Creating Answer File Step Failed."
Write-Information $true ("Reason: " + $error[0])
Export-ReleaseHandles
exit
}
Write-Information $true ("Answer File is successfully created: " + $cloneConfigAnswer)
}
Export-ReleaseHandles
# SIG # Begin signature block
# MIIbAwYJKoZIhvcNAQcCoIIa9DCCGvACAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU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