Powershell

AppAssure powershell commandlets for administrators

This article focuses on useful, helpful, and powerful AppAssure powershell commandlets that can help you take control of your environment.

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.

aaps01

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.

aaps02

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.

Subscribe to VirtualizationHowto via Email ๐Ÿ””

Enter your email address to subscribe to this blog and receive notifications of new posts by email.



Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com, and a 7-time VMware vExpert, with over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, He has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family. Also, he goes through the effort of testing and troubleshooting issues, so you don't have to.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.