The Get-ProtectedServers PowerShell cmdlet which is part of the AppAssure PowerShell Module that’s installed on your AppAssure Core server version 5.3.1 or higher allows you to determine what servers are being protected by a particular AppAssure Core server.
Since I’m running PowerShell version 3 on the AppAssure Core server shown in the example below, I didn’t have to explicitly import the AppAssure PowerShell module, if you’re running PowerShell version 2, you would need to run Import-Module AppAssurePowerShellModule prior to running the Get-ProtectedServers cmdlet. The following example shows that you can retrieve some useful information with the Get-ProtectedServers cmdlet by simply running it without any parameters:
To determine what other properties are available for this cmdlet, just like any other cmdlet that produces output, pipe it to Get-Member. One thing to note is the column headers such as “Display Name” and “Is Paused” as shown in the previous example which have a space between the words are not the actual property names. The property name for each of these items as shown in the following results doesn’t contain a space between the words:
I want to filter the output of the Get-ProtectedServers cmdlet down to a subset so I’ll view the full help for this cmdlet to determine if it has any parameters to filter with:
Based on the results of the full help in the previous image, there are no parameters for filtering left so we’ll have to resort to piping our results to the Where-Object cmdlet and perform our filtering with that cmdlet. I only want to return a list of servers that should be protected by this AppAssure Core server where the current status is not equal to protected (show me any servers with a status other than protected):
Note: Each of the following examples use the new PowerShell version 3 simplified Where-Object syntax.
I’ve been working on updating these client agents to the latest version of AppAssure so the problem is probably that the AppAssure Agent service is not running on those particular servers. Now I only want to retrieve a list of just the server names where the status is not protected. By using the -expand property with the Select-Object cmdlet, the server names are returned as strings without a column header:
PowerShell remoting is enabled on all of the servers in this environment. I’m now going to place the command we previously created inside of parentheses to feed the Invoke-Command cmdlet the list of server names that aren’t currently protected to determine what the status of the AppAssureAgent service is on them:
Let’s modify the previous command slightly to attempt to start the AppAssureAgent service on each of these servers. I’ve replaced the Get-Service cmdlet with the Start-Service cmdlet. I’ve also added the -Passthru parameter since the Start-Service cmdlet doesn’t return any results by default and I want to see what the results are without having to run another PowerShell command:
Now that all of the agents are protected, I want to see which ones are still in need of updating. I’ll sort the results so the servers with the out of date agents are listed first:
Let’s refine that list a little more and only return a list where the version is not equal to the latest version. The sorting isn’t really necessary in this scenario, although if more than one previous version of the AppAssure agent was on different servers, it would have mattered:
Looks like I have three more servers to update the AppAssure agent on and all of them will be updated, then I can move on to doing more fun stuff with PowerShell.