Install Attunity Replicate using the AttunityReplicate__X64.exe installation kit. This kit runs on Windows 64-bit (x64) environments. All of the data that is created when you use Attunity Replicate is stored in a directory called data. By default, this directory is located in the installation directory where you install Attunity Replicate. If you want to create the data directory in a different location, select this option in the installation wizard. If you elect to create the data directory in a different location, all command-line actions must include the -d your_data_directory_path parameter where your_data_directory_path is the location of the “data” directory.
- Below Powershell perform Install/Upgrade based on the software version to you give it.
- For a fresh installation, it goes and checks whether the software is installed or not! if it is not installed, then it is going to perform install.
- Open Powershell with Administrator user
-
InstallUpgrade_AttunityReplicate.ps1 -softwareversion '6.4.0.532'
- For Upgrade, Please follow the below steps before you execute the script.
- Stop all Replicate tasks and services
- Back up the Replicate “data” directory to a location outside the product folder. This method is recommended in most cases. However, if your “data” folder is very large and there is not enough space to back it up, then use Open a Windows command prompt and change the path to \bin.
-
Then issue the following command: repctl [-d alternate_data_directory_path] exportrepository where [-d alternate_data_directory_path] is required when the Replicate "data" directory is in a non-default location.
-
- It checks the existing software version in the server and if the given input software version is greater than installed then it performs upgrade.
-
InstallUpgrade_AttunityReplicate.ps1 -softwareversion '6.4.0.532'
-
Make changes according to your Environment, I hope you like it.
Param(
[Parameter(Mandatory = $true, Position = 1)][string] $softwareversion
, [Parameter(Mandatory = $false, Position = 2)][ValidateSet('List', 'Uninstall', 'Check', 'Help')] $Action = 'LIST'
, [switch]$help
)
#Formating
$Root = 'C:\Program Files\Attunity\Replicate'
$Data = 'D:\Attunity\Replicate\data'
$machine = $env:computername.ToLower() + "." + $env:USERDOMAIN.ToLower() + ".com"
$service = 'AttunityReplicateServer'
$software = 'Attunity Replicate'
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $software })
$installfolderpath = "C:\Attunity\Replicate\Install"
$uninstallfolderpath = "C:\Attunity\Replicate\Uninstall"
$upgradefolderpath = "C:\Attunity\Replicate\Upgrade_$softwareversion"
$areplicatefile = "$installfolderpath\AttunityReplicate_$softwareversion" + "_X64.exe"
$upgradeareplicatefile = "$upgradefolderpath\AttunityReplicate_$softwareversion" + "_X64.exe"
$uninstallareplicatefile = "$uninstallfolderpath\AttunityReplicate_$softwareversion" + "_X64.exe"
$7zipPath = "C:\Program Files\7-Zip\7z.exe"
$Repctl = $Root + '\bin\repctl.exe' -replace '\\program files', '\\"program files"'
$TempD = '-d ' + 'C:\Temp' + ''
#$URL = "/AttunityReplicate_$softwareversion" + "_X64.exe"
$areplicate_install_iss = @"
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-DlgOrder]
Dlg0={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdWelcome-0
Count=7
Dlg1={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdLicense2Rtf-0
Dlg2={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdAskDestPath-0
Dlg3={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdAskDestPath-1
Dlg4={9C614355-28A0-4C2A-98DF-DB9FD674826F}-AskOptions-0
Dlg5={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdStartCopy-0
Dlg6={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdFinish-0
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdWelcome-0]
Result=1
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdLicense2Rtf-0]
Result=1
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdAskDestPath-0]
szDir=$Root
Result=1
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdAskDestPath-1]
szDir=$Data
Result=1
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-AskOptions-0]
Result=1
Sel-0=1
Sel-1=0
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdStartCopy-0]
Result=1
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0
"@
$areplicate_uninstall_iss = @"
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-DlgOrder]
Dlg0={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdWelcomeMaint-0
Count=3
Dlg1={9C614355-28A0-4C2A-98DF-DB9FD674826F}-MessageBox-0
Dlg2={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdFinish-0
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdWelcomeMaint-0]
Result=303
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-MessageBox-0]
Result=6
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0
"@
$areplicate_upgrade_iss = @"
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-DlgOrder]
Dlg0={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdWelcome-0
Count=2
Dlg1={9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdFinish-0
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdWelcome-0]
Result=1
[{9C614355-28A0-4C2A-98DF-DB9FD674826F}-SdFinish-0]
Result=1
bOpt1=0
bOpt2=0
"@
$help_text = @"
Install & Upgrade
"@
#
# Convert inputs to Upper Case, handle HELP request
#
$Action = $Action.ToUpper()
if (($action -eq 'HELP') -or ($help) ) { $help_text; exit }
#Function that logs a message to a text file
$LogFile = "C:\Attunity\Replicate\areplicate_$softwareversion.log"
#Delete log file if it exists
if (Test-Path $LogFile) {
Remove-Item $LogFile
}
#Start Logging
Start-Transcript -Path $LogFile
#Checks if service exists and provides ServiceStatus
function CheckMyService ($service) {
if (Get-Service $service -ErrorAction SilentlyContinue) {
$ServiceStatus = (Get-Service -Name $service).Status
$ServiceStatus
}
else {
Write-Host "$service not found"
}
}
# Check Software is Install or not, If software version is changed from policy file then it will get upgraded to latest software.
if ($installed.DisplayName -match $software) {
if ($installed.DisplayVersion -ge $softwareversion) {
Write-host "----------------------------------------------------------------"
Write-Host "Current $Software Software on this $machine is" $installed.DisplayVersion -ForegroundColor "red"
Write-host "----------------------------------------------------------------"
Write-Host "you are on new software! No Need to Upgrade" -ForegroundColor "Green"
Write-host "----------------------------------------------------------------"
# Checking for Services
if (CheckMyService -eq "Running") {
Write-Output ("$service -- Service is Running" )
Write-host "----------------------------------------------------------------"
}
elseif (CheckMyService -eq "Stopped") {
Write-Output ("$service -- Service is Stopped" )
Write-host "----------------------------------------------------------------"
}
else {
Write-Host "Unable to check services status, please check in $software registry"
}
}
else {
Write-host "----------------------------------------------------------------"
Write-Host "You are on Old Software! Performing Upgrade $software on $machine" -ForegroundColor "white" -BackgroundColor "Green"
Write-host "----------------------------------------------------------------"
#Copying Data
#Back up the Replicate "data" directory configuration to a Temp Directory
try {
Invoke-Expression "$Repctl $TempD exportrepository"
}
catch {
# This will just write the error
Write-Host "Unable to export Data repository returned the following error $_"
}
if (CheckMyService -eq "Running|Stopped") {
Write-Output ("Already $service Service is Running or Stopped")
# Cleanup Old Installer & Uninstall Exe file from folders
Remove-Item -Path $installfolderpath\* -Recurse
Remove-Item -Path $uninstallfolderpath\* -Recurse
# Check for Script Directory & iss file
if (Test-Path "$upgradefolderpath") {
Write-Output "The folder '$upgradefolderpath' already exists, will not recreate it."
}
else {
mkdir "$upgradefolderpath"
}
if (Test-Path "$upgradefolderpath\areplicate_upgrade.iss") {
write-host "The file '$upgradefolderpath\areplicate_upgrade.iss' already exists, removing..."
Remove-Item -Path "$upgradefolderpath\areplicate_upgrade.iss" -Force
}
else {
}
# Create file:
write-host "Creating '$upgradefolderpath\areplicate_upgrade.iss'..."
New-Item -Path "$upgradefolderpath\areplicate_upgrade.iss" -ItemType File -Value $areplicate_upgrade_iss
# Start Downloading software.exe Package for Software
$filepath = "$upgradefolderpath\dbadeedsattunityreplicate.$softwareversion.nupkg"
if (!(Test-Path $filepath)) {
write-host "Downloading $software software.exe Package from Delivery Pipeline--" -nonewline
$clnt = New-Object System.Net.WebClient
$clnt.DownloadFile($url, $filepath)
Write-Host "Downloading File is completed!" -ForegroundColor Green
}
else {
write-host "Found the software.exe package, no need to download it..."
}
if (-not (Test-Path -Path $7zipPath -PathType Leaf)) {
throw "7 zip file '$7zipPath' not found"
}
else {
# Unzip or 7zip the software.exe Package
write-host "Unzipping the software.exe Package" -ForegroundColor Green
Set-Alias 7zip $7zipPath
Set-Location -Path $upgradefolderpath
7zip x -aou -mx=9 $filepath *.exe
}
write-host "Please Wait About to Upgrade AttunityReplicate..."
$upgradeParms = "/s /f1$upgradefolderpath\areplicate_upgrade.iss /f2$upgradefolderpath\areplicate_upgrade_$softwareversion.log"
$upgradePrms = $upgradeParms.Split(" ")
Write-Host $upgradeareplicatefile
if (-not (Test-Path -Path $upgradeareplicatefile)) {
throw "Attunity Replicate EXE file not Found"
}
else {
try {
Start-Process "$upgradeareplicatefile" -argumentlist "$upgradePrms" -wait
}
catch {
# This will just write the error
Write-Host "AttunityReplicate.exe returned the following error $_"
# If you want to pass the error upwards as a system error and abort your powershell script or function
Throw "AttunityReplicate.exe $_"
}
Write-Host "Done! $Software is Upgrade Successfully" -ForegroundColor Green
Copy-Item -Path $upgradeareplicatefile -Destination $uninstallfolderpath -Recurse
}
}
else {
Found $software registy! but unable to upgrade. please check on the server
}
}
}
else {
Write-host "----------------------------------------------------------------"
Write-Host "Software is not Installed on this $machine server" -ForegroundColor "red"
Write-host "----------------------------------------------------------------"
Write-Host "Installation $software on this $machine server" -foregroundcolor "white" -backgroundcolor "Green"
Write-host "----------------------------------------------------------------"
# below variables are customizable
# Check for Script Directory & iss file
if (Test-Path "$installfolderpath") {
Write-Output "The folder '$installfolderpath' already exists, will not recreate it."
}
else {
mkdir "$installfolderpath"
}
if (Test-Path "$installfolderpath\areplicate_install.iss") {
write-host "The file '$installfolderpath\areplicate_install.iss' already exists, removing..."
Remove-Item -Path "$installfolderpath\areplicate_install.iss" -Force
}
else {
}
# Create file:
write-host "Creating '$installfolderpath\areplicate_install.iss'..."
New-Item -Path "$installfolderpath\areplicate_install.iss" -ItemType File -Value $areplicate_install_iss
# Start Downloading software.exe Package for Software
$filepath = "$installfolderpath\dbadeedsattunityreplicate.$softwareversion.nupkg"
if (!(Test-Path $filepath)) {
write-host "Downloading $software software.exe Package from Delivery Pipeline--" -nonewline
$clnt = New-Object System.Net.WebClient
$clnt.DownloadFile($url, $filepath)
Write-Host "Downloading File is completed!" -ForegroundColor Green
}
else {
write-host "Found the software.exe package, no need to download it..."
}
if (-not (Test-Path -Path $7zipPath -PathType Leaf)) {
throw "7 zip file '$7zipPath' not found"
}
else {
#Unzip or 7zip the software.exe Package
write-host "Unzipping the software.exe Package" -ForegroundColor Green
Set-Alias 7zip $7zipPath
Set-Location -Path $installfolderpath
7zip x -aou -mx=9 $filepath *.exe
}
$installParms = "/s /f1$installfolderpath\areplicate_install.iss /f2$installfolderpath\areplicate_install.log"
$installPrms = $installParms.Split(" ")
if (-not (Test-Path -Path $areplicatefile)) {
throw "Attunity Replicate EXE file not Found"
}
else {
# start the AttunityReplicate installer
write-host "About to install AttunityReplicate..."
try {
Start-Process "$areplicatefile" -argumentlist "$installPrms" -wait
}
catch {
# This will just write the error
Write-Host "AttunityReplicate.exe returned the following error $_"
# If you want to pass the error upwards as a system error and abort your powershell script or function
Throw "AttunityReplicate.exe $_"
}
Write-host "----------------------------------------------------------------"
Write-Host "Done! $Software is Installed Successfully" -ForegroundColor Green
Write-host "----------------------------------------------------------------"
Copy-Item -Path $areplicatefile -Destination $uninstallfolderpath -Recurse
Write-Host "Stopping! $software services & set login password with service account to services" -ForegroundColor Green
# Stopping Services
$allservices = Get-Service -Name AttunityReplicate*
ForEach ( $getname in $allservices ) {
if ( $getname.Status -eq "Stopped" ) {
Write-Host $getname.Name, $getname.status -ForegroundColor Red
}
else {
Write-Host $getname.Name, $getname.status -ForegroundColor Green
Write-Host "Attempting to stop, Please wait..." $getname.Name
Stop-Service -Name $getname.Name -ErrorAction SilentlyContinue
}
}
}
}
switch ($Action) {
LIST {
Write-Host "List of Operation you can perform"
Write-Host "To Uninstall your software C:\Attunity\Common\Scripts\manage_areplicate.ps1 -softwareversion '6.4.0.316' -Action Uninstall"
Write-Host "To Status your software C:\Attunity\Common\Scripts\manage_areplicate.ps1 -softwareversion '6.4.0.316' -Action Check"
}
UNINSTALL {
if ($installed.DisplayName -match 'Attunity Replicate') {
Write-host "----------------------------------------------------------------"
Write-Host "Software is Installed on this $machine server" -ForegroundColor "white" -BackgroundColor "Red"
Write-host "----------------------------------------------------------------"
if (CheckMyService -eq "Running|Stopped") {
Write-Output ("Already $service Service is Running or Stopped")
Write-host "----------------------------------------------------------------"
Write-Host "Perform Uninstall $software on $machine" -ForegroundColor "white" -BackgroundColor "Green"
Write-host "----------------------------------------------------------------"
if (Test-Path "$uninstallfolderpath") {
Write-Output "The folder '$uninstallfolderpath' already exists, will not recreate it."
}
else {
mkdir "$uninstallfolderpath"
}
if (Test-Path "$uninstallfolderpath\areplicate_uninstall.iss") {
write-host "The file '$uninstallfolderpath\areplicate_uninstall.iss' already exists, removing..."
Remove-Item -Path "$uninstallfolderpath\areplicate_uninstall.iss" -Force
}
# Re-Create file:
write-host "Creating '$uninstallfolderpath\areplicate_uninstall.iss'..."
New-Item -Path "$uninstallfolderpath\areplicate_uninstall.iss" -ItemType File -Value $areplicate_uninstall_iss
Set-Location -Path $uninstallfolderpath
if (!(Test-Path $uninstallareplicatefile)) {
Write-Host "Unable to find $software Installer EXE File in the $uninstallfolderpath please check!" -ForegroundColor Green
#Download Installer file.
write-host "Downloading $software software.exe Package from Delivery Pipeline--" -nonewline
$clnt = New-Object System.Net.WebClient
$clnt.DownloadFile($url, $filepath)
Write-Host "Downloading File is completed!" -ForegroundColor Green
}
else {
write-host "Found $software Installer EXE File, no need to download it..Now Perform Uninstaller!" -ForegroundColor Green
$uninstallParms = "/s /f1$uninstallfolderpath\areplicate_uninstall.iss /f2$uninstallfolderpath\areplicate_uninstall_$softwareversion.log"
$uninstallPrms = $uninstallParms.Split(" ")
write-host "Set Location $software to installer exe Directory to Uninstall.. "
write-host "Please wait About to uninstall AttunityReplicate......."
try {
Start-Process "$uninstallareplicatefile" -argumentlist "$uninstallPrms" -wait
}
catch {
# This will just write the error
Write-Host "AttunityReplicate.exe returned the following error $_"
# If you want to pass the error upwards as a system error and abort your powershell script or function
Throw "AttunityReplicate.exe $_"
}
Write-Host "Done! $Software is UnInstalled Successfully" -ForegroundColor Green
}
}
else {
Found $software registry! but unable to uninstall. please check on the server
}
}
else {
Write-host "----------------------------------------------------------------"
Write-Host "Software is not Installed on this $machine server" -ForegroundColor "red"
Write-host "----------------------------------------------------------------"
}
}
CHECK {
Write-Host "Software Details for $software on this $machine"
$installed
}
default {
throw "Action $Action is NOT a valid choice" # Cannot get here. Caught by 'validateset' ?!
}
} # switch
#Stop Logging
Stop-Transcript
Leave a comment