Powershell

Powershell Script to check if AppAssure agent is installed on Servers

Powershell Script to check if AppAssure agent is installed on Servers

If you run Dell’s AppAssure backup software in your environment and have a multitude of servers, it is handy to be able to see which servers in your environment have the agent installed and which ones potentially do not.  Using powershell we can easily query the services installed on a list of servers and find which ones have the service running and which do not.

$result = @()

$name = "AppAssureAgent"
$servers = Get-Content c:\servers.txt
$cred = Get-Credential

foreach($server in $servers) {
  Try {
    $s = gwmi win32_service -computername $server -credential $cred -ErrorAction Stop | ? { $_.name -eq $name }
    $o = New-Object PSObject -Property @{ server=$server; status=$s.state }
    $result += ,$o
  }
  Catch {
    $o = New-Object PSObject -Property @{ server=$server; status=$_.Exception.message }
    $result += ,$o
  }
}

$result | out-file c:\appassure_status.txt

In the above script we are simply querying a list of servers (servers.txt) for the name of the service in question – AppAssureAgent – and then spitting the results out into a results file called appassure_status.txt.  You can customize any of the names you want as they are insignificant.  Keep in mind that with the powershell script above, you will need to run the script using credentials that have access to the servers in question to be queried.

The results will look similar to the following:

server         status                                                                                                  
------         ------                                                                                                  
testsql        Running                                                                                                 
devbox01                                                                                                                  
loadtest       Running                                                                                                 
sqlserv1       Running                                                                                                 
atlanta        Running                                                                                                 
boston         Running                                                                                                 
orion                                                                                                                 
dc1                                                                                                            
dssql          Running                                                                                                 
dssql02        Running

You can spice up the output as you wish and really the sky is the limit on styling and other output customization.  However, the above is a plain and simple result return that can quickly help you to see the servers in your environment with the AppAssure Agent installed and running.

Also, the above code snippet is not of course limited to AppAssureAgent.  You can change the name of the service to any service that you wish to check the status of in determining if it is installed and running.

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.