Script repository
The script copies the changes made to UI texts from one Adaxes configuration to another. If a string was not modified for a language, it will not be copied.
Execute the script in Windows PowerShell on the computer where Adaxes service from which the settings will be copied is installed. When prompted, first specify the credentials of the source instance Adaxes service account (specified during Adaxes installation) and then those of the target instance.
Parameters
$adaxesServiceSourceName- the host name of the Adaxes service to copy the changes from.$adaxesServiceTargetName- the host name of the Adaxes service to copy the changes to.$sourceWebUIName- the name of the Adaxes web interface to copy the changes from.$tragetWebUIName- the name of the Adaxes web interface to to copy the changes to.$languagesToCopy- two letter codes (e.g. de) of the languages to copy the changes for. To copy the changes for all languages, set the variable to an empty array.
Import-Module Adaxes
$adaxesServiceSourceName = "AdaxesServiceSource.example.com" # TODO: modify me
$adaxesServiceTargetName = "AdaxesServiceTarget.example.com" # TODO: modify me
$sourceWebUIName = "SourceWebUI" # TODO: modify me
$tragetWebUIName = "TargetWebUI" # TODO: modify me
$languagesToCopy = @("ar", "se") # TODO: modify me
# Prompt for credentials.
$adaxesServiceSourceCred = Get-Credential -Message "Enter credentials for $adaxesServiceSourceName Adaxes service"
$adaxesServiceTargetCred = Get-Credential -Message "Enter credentials for $adaxesServiceTargetName Adaxes service"
# Get languages from source service.
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly($adaxesServiceSourceName)
$webuiConfigPath = $admService.Backend.GetConfigurationContainerPath("WebUIConfigurationContainer")
$webuiConfigContainer = $admService.OpenObject($webuiConfigPath, $adaxesServiceSourceCred.UserName, $adaxesServiceSourceCred.GetNetworkCredential().Password, 0)
$sourceWebuiConfig = $webuiConfigContainer.GetConfig($sourceWebUIName)
$translationsJson = $sourceWebuiConfig.ToJson('{elements: ["translations"]}')
# Bind to target web interface.
$admService = $admNS.GetServiceDirectly($adaxesServiceTargetName)
$webuiConfigPath = $admService.Backend.GetConfigurationContainerPath("WebUIConfigurationContainer")
$webuiConfigContainer = $admService.OpenObject($webuiConfigPath, $adaxesServiceTargetCred.UserName, $adaxesServiceTargetCred.GetNetworkCredential().Password, 0)
$targetWebuiConfig = $webuiConfigContainer.GetConfig($tragetWebUIName)
# Set languages to target service.
if ($languagesToCopy.Length -eq 0)
{
$targetWebuiConfig.FromJson($null, $translationsJson)
}
else
{
$translationsToUpdate = @()
$translations = $translationsJson | ConvertFrom-Json
foreach ($translation in $translations.Translations)
{
if ($languagesToCopy -notcontains $translation.Language)
{
continue
}
$translationsToUpdate += $translation
}
if ($translationsToUpdate.Length -eq 0)
{
return
}
$translations.translations = $translationsToUpdate
$translationsJson = $translations | ConvertTo-Json -Depth 4
$targetWebuiConfig.FromJson($null, $translationsJson)
}
Comments 0
You must be signed in to comment.