Affected Builds
AppAssure 5.x
Introduction
This article details the steps necessary to check active jobs in real-time using PowerShell.
Description
The AppAssure PowerShell module provides customers with the ability to check the progress of all active, running jobs in real-time without opening the Core Console.
Warning: All scripts provided in this article are meant to be used as examples and are not supported by AppAssure. For more information on Dell | AppAssure scripting support, click here.
Solution
The following script will check all active jobs in real-time. This script should be run from an elevated PowerShell console on either the Source or Target Core. Prior to running the script, please note the following:
- The script runs indefinitely, “catching” the active jobs on the selected core and updating them in semi real-time (i.e. every second).
- When possible, progress is tracked both in MB and percentages. Due to the limitations of the AppAssure PowerShell module, this is not always possible. For instance, in AppAssure 5.3, the replication progress can be tracked from the Target Core but not on the Source Core.
- The script can be exited gracefully by pressing the Q key or by hard stop using Ctrl-c.
#You may need the line below; try without it first
#[System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”)
Write-host
Write-host “Real Time AppAssure Active Jobs Monitor”
Write-host “—————————————”
Write-host Hit “Q” to exit.
$Qkey = 81 #value of Quit key
#get the name of the core to monitor. Local machine is default
$corename = Read-Host “Enter the name of the Core to monitor [default $($env:computername)]”
if ($corename -eq “”) {$corename = $env:computername}
Write-host
#check if the appassure powershell module is installed
$module = “appassurepowershellmodule”
if (-not(Get-module -name $module)) {import-module appassurepowershellmodule}
Write-host “$($module) is installed”
#starting Position
$StartPos = [console]::CursorTop
#make a filler row; there are better ways to achive this, though
for ($j=1; $j -lt [console]::WindowWidth; $j++){$m+= ” “}
#set the max y position
$maxpos = $StartPos
For (;;) #dummy loop
{
#Set starting Point
[Console]::SetCursorPosition(0,$StartPos)
#Get Active Jobs
$jobs = get-activejobs -all -core $corename
#Prepare the table with the active jobs
$jobs | Format-Table -Wrap -property @{n=”Summary”; e={$_.Summary};width=20}, Status,
@{n=”Total Work”;e={“{0:N2}” -f ($_.TotalWork/1MB)+”MB”}},
@{n=”Progress”;e={“{0:N2}” -f ($_.Progress/1MB)+”MB”}},
@{n=”PercentComplete”;e={“{0:N2}” -f ($_.Progress/$_.TotalWork*100)+”%”}},
StartTime | out-default
#Get the last position of the cursor
$Endpos = [console]::CursorTop
#Wait for a second
start-sleep -m 1000
#get the screen area to be cleaned
if ($maxpos -Lt $Endpos){$maxpos = $Endpos}
#set cursor location to begin cleaning
[Console]::SetCursorPosition(0,$Endpos-2)
#clean area
for ($i=$endPos; $i -le $maxpos; $i++) {$m}
#exit the loop
if ($host.ui.RawUi.KeyAvailable)
{
$key = $host.ui.RawUI.ReadKey(“NoEcho,IncludeKeyUp”)
if ($key.VirtualKeyCode -eq $Qkey)
{
Write-host
Write-host
Write-Host “Exiting…”
Write-host
break
}
}
}