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.