Friday, July 28, 2017

How to inventory all Repliweb Jobs

Recently got an opportunity to explore Attunity's Repliweb, a content deployment tool which can deploy packages across multiple targets from a source code repository. Although the GUI tool provides options to manage the deployment and their resulting logs, it lacks options to export the inventory of all jobs.

But it exposes API via PowerShell to take the inventory. As I was not able to find such script anywhere, thought of sharing it via this post.

Below script creates a csv file in the current directory which will contain all jobs along with their status and edges list.

Fetches all jobs from Repliweb center
Fetches all jobs from Repliweb center
.PARAMETER username
A repliweb username
.PARAMETER password
A repliweb password for the username provided
Domain name for the username
.\fetchJobs.ps1 -username "JohnDoe" -password "secretword" -domain "contoso"
Run this script in a repliweb center's powershell console as administrator.

[string] $username,

[string] $password,

[string] $domain

if ((Get-PSSnapin -Name r1_ps_api -ErrorAction SilentlyContinue) -eq $null )
      Add-PsSnapin r1_ps_api

## Global Constants
$fileName="$($env:Computername)_$(get-date -format `"yyyyMMdd_hhmmsstt`").txt"
$currentDir=Split-Path $script:MyInvocation.MyCommand.Path
$logfile =  join-path $currentDir $fileName

## Global functions:
function write-log([string[]]$logline)
  $logline | out-file -Filepath $logfile -append

#$R1Session.QueryFilter.JobType= "R1_DISTRIBUTION"
write-host " Session established and jobs retrieved"
write-log $header
foreach($job in $jobs)
$edges='' = DistributionInfo or MSIInfo
foreach($edge in $
$edges+= $edge + ";"
 $logline=$job.Id + "," + $job.Name + "," + $job.Type + "," + $job.State + "," + $job.SourceDirectory + "," + $job.Stage + "," + $edges
write-log $logline
write-host " Export process completed."