AppAssure powershell commandlets for administrators
If you administer an AppAssure environment, there is great power in using Powershell to do a lot of the heavy lifting. There are just some things about GUIs we all love to hate and the AppAssure GUI is no exception to that. As with many bulk operations, powershell is the way to go with AppAssure. Thankfully it has many command operations that can be accomplished with powershell. Let’s take a look at a few helpful AppAssure powershell commandlets.
AppAssure powershell commandlets
Stopping and starting the core service
The following commandlets will stop the service and start the service. You will see a “waiting for service ‘AppAssure core service (AppAssureCore)’ to stop…” and a “Waiting for service ‘AppAssure Core Service (AppAssureCore)’ to start…” as the service is stopped and started respectively.
stop-service appassure* start-service appassure*
Stopping Active Jobs running
Stop-activejobs -all
Seeing Active Jobs that are running
Get-activejobs -all
Suspending Snapshots (i.e. to prep for stopping core service)
suspend-snapshot -all
Suspend replication jobs either incoming or outgoing
Depending on the direction of your replication, you can stop it from either side, source or target core.
suspend-replication -incoming appassureserver1 -all suspend-replication -outgoing appassureserver2 -all
See running tasks in realtime with progress
for(;;){get-activejobs -all | select-object -expandproperty childjobsinfo | format-table summary,status,progress,estimatedtimeremaining;start-sleep 3;cls}
The commandlet above creates a nice formatted table view that updates in real time to show running tasks and their progress through the tasks being ran.
Cancel Queued Jobs
When you run the stop-activejobs -all it only stops the jobs that are running not queued. The following script cancels queued jobs:
<# .Synopsis Cancel queued jobs .Description Queued jobs may be canceled using this script. The script runs either on a one time basis or in an infinite loop. If this is the case it may be stopped by hitting ctrl-c .Parameter donotstop enables the infinite loop .Example .cancelqueuedjobs .Example .cancelqueuedjobs -donotstop #> param([switch]$donotstop) cls $starttime = get-date $duration=$null $i=$null for(;;){ $ajobs = get-activejobs -all | where {$_.status -eq "Queued"} $x=$ajobs.count if($x -le 0){$x = $null} if($i){$duration = "(running for $((New-TimeSpan -start $starttime -end (get-date)).ToString().substring(0,11)))"} Write-Host "`nCancelling $x Queued Jobs Loop $i $duration" -ForegroundColor Green $i++ foreach ($ajob in $ajobs){ $protectedserver = $ajob.summary $jobid = $ajob.Id Write-Host "Cancelling queued job: $protectedserver" -f Yellow Invoke-RestMethod -Uri "https://$($env:computername):8006/apprecovery/api/core/jobmgr/jobs/$jobId" -Method DELETE -UseDefaultCredentials } if(!($donotstop)){ break } start-sleep 180 }
Rollup Job using Powershell
Recently, in working with a problem with rollups on a couple of core servers, I discovered, there is a rollup script available for download from AppAssure support: https://i.dell.com/sites/csdocuments/Shared-Content_campaigns_Documents/en/Alder_Spec_Sheet_v3.pdf
The powershell script is superior to the builtin rollup job in that it doesn’t create contention for other jobs running. You most likely have observed the builtin job blocks any other jobs from running until ALL of the rollups are complete and this can take quite some time. The powershell script however, only rolls up one machine at a time and will only block another job if it is the same machine the script is rolling up. The beauty is your rollups can be running simultaneously with other jobs such as replication, etc and the rollup job doesn’t create the blocking condition as the built in job does.
Visit the link I embedded above and at the bottom of the KB article, you can download the script in full. After the script is downloaded, you can then schedule a task to run at some point in the day to kick off the rollup job via the powershell script.
Final Thoughts
Powershell is a great way to administer your AppAssure environment. These are only a few of the useful commands that can be leveraged to make your life easier managing your AppAssure servers.