#Select which instance to upgrade the config for $instanceToUpgrade = "InstanceName" #Path to the Datastore.json file. Located in the Scripts folder below Profitbase Installation Manager $pathToDatastoreJson = "D:\InstallManager\Datastore.json" #Path to the Instance Template should be in the same folder as Datastore.json $pathToInstanceTemplate = "D:\InstallManager\instancetemplate.json" #Load files $datastore = Get-Content $pathToDatastoreJson -Raw | ConvertFrom-Json $datastoreNew = Get-Content $pathToDatastoreJson -Raw | ConvertFrom-Json $template = Get-Content $pathToInstanceTemplate -Raw | ConvertFrom-Json Write-Output "Read Datastore and Instance Template json files" #Backup Datastore.json file Copy-Item $pathToDatastoreJson "$pathToDatastoreJson.old" -Force #Clear the target instances list $datastoreNew.InVision.Instances = @() # Total number of instances $numberOfInstancesTotal = $datastore.InVision.Instances.Count $numberOfInstancesUpgraded = 0 foreach ($instance in $datastore.InVision.Instances) { if ($instance.instance -eq $instanceToUpgrade) { Write-Output "Upgrading instance: " $instance.instance $numberOfInstancesUpgraded++ $template.instance = $instance.instance $template.General.concurencyControl = $instance.General.concurencyControl $template.General.serviceUser = $instance.General.serviceUser $template.General.serviceUserPassword = $instance.General.serviceUserPassword $template.General.fileName = $instance.General.fileName $template.General.path = $instance.General.path $template.General.versionInfo = $instance.General.versionInfo $template.Monitoring.ApplicationInsightsInstrumentationKey = $instance.Monitoring.ApplicationInsightsInstrumentationKey $template.Monitoring.SendInterval = $instance.Monitoring.SendInterval $template.Monitoring.DeploymentId = $instance.Monitoring.DeploymentId $template.Monitoring.LicenseId = $instance.Monitoring.LicenseId $template.IIS.websiteName = $instance.IIS.websiteName $template.IIS.clientName = $instance.IIS.clientName $template.IIS.https = $instance.IIS.https $template.IIS.websitePort = $instance.IIS.websitePort $template.IIS.websiteDomain = $instance.IIS.websiteDomain $template.Database.databaseServer = $instance.Database.databaseServer $template.Database.databaseName = $instance.Database.databaseName $template.Database.databaseUser = $instance.Database.databaseUser $template.Database.databasePassword = $instance.Database.databasePassword $template.Database.collation = $instance.Database.collation $template.Authentication.AuthenticationType = $instance.Authentication.AuthenticationType $template.Authentication.Windows.ADConnectionString = $instance.Authentication.Windows.ADConnectionString $template.Authentication.AzureAD.Client.clientId = $instance.Authentication.AzureAD.Client.clientId $template.Authentication.AzureAD.Client.authority = $instance.Authentication.AzureAD.Client.authority $template.Authentication.AzureAD.Client.clientSecret = $instance.Authentication.AzureAD.Client.clientSecret $template.Authentication.AzureAD.Client.tenant = $instance.Authentication.AzureAD.Client.tenant $template.Authentication.AzureAD.Designer.clientId = $instance.Authentication.AzureAD.Designer.clientId $template.Authentication.AzureAD.Designer.redirectUri = $instance.Authentication.AzureAD.Designer.redirectUri $template.EventBusSettings.EventBusType = $instance.EventBusSettings.EventBusType $template.EventBusSettings.AzureServiceBus.BroadcastTopic = $instance.EventBusSettings.AzureServiceBus.BroadcastTopicConnectionString $template.EventBusSettings.AzureServiceBus.DispatcherQueue = $instance.EventBusSettings.AzureServiceBus.DataFlowCommandQueueConnectionString $template.EventBusSettings.AzureServiceBus.WorkerQueue = $instance.EventBusSettings.AzureServiceBus.DispatcherEventQueueConnectionString $template.EventBusSettings.AzureServiceBus.SystemWorkerQueue = $instance.EventBusSettings.AzureServiceBus.SystemWorkerCommandQueueConnectionString # New in 2022.2 $template.EventBusSettings.AzureServiceBus.SchedulerQueue = "" $template.EventBusSettings.RabbitMQ.HostName = $instance.EventBusSettings.RabbitMQ.HostName $template.EventBusSettings.RabbitMQ.VirtualHost = $instance.EventBusSettings.RabbitMQ.VirtualHost $template.EventBusSettings.RabbitMQ.UserName = $instance.EventBusSettings.RabbitMQ.UserName $template.EventBusSettings.RabbitMQ.Password = $instance.EventBusSettings.RabbitMQ.Password $template.EventBusSettings.RabbitMQ.RetryCount = $instance.EventBusSettings.RabbitMQ.RetryCount $datastoreNew.InVision.Instances += $template }else{ $datastoreNew.InVision.Instances += $instance } } Write-Output "##############################################################" Write-Output "Upgraded $numberOfInstancesUpgraded of $numberOfInstancesTotal instances" #Write file to disk again $datastoreNew | ConvertTo-Json -Depth 99 | Out-File $pathToDatastoreJson