In the case of VMware Virtual Machine protection, this most likely isn’t necessary since you probably are using VM Image level protection right? I hope so! But there are cases when a more granular backup is desired. This can useful if you want to target backups in the operating system for specific files, or specific applications. In this case you will need to install an Avamar agent in the guest VM in order to do the guest OS operations and source-based dedupe. The following post will give you the capability to completely automate, if desired, the install process of the Avamar guest agent as well as application agents. This is meant for installs, but can be used for upgrades as well.
So how can we accomplish this? In PowerCLI there are a couple of commonly used cmdlets called Copy-VMGuestFile and Invoke-VMScript which allow you to transfer files and execute commands from a specified user account without the VM having a network connection. The communication happens between the hypervisor and the VM. The operation of the module is simple, you can either leverage the remote install capability in a on-demand or fully planned manner (CSV file).
As always, please do your own testing prior to use anywhere outside a lab to ensure you understand how this operates!
Pre-Requisites (as developed)
- PowerCLI 5.1 Release 1 and Powershell 3 (should work on prior versions as well)
- Avamar 6.1 (should work on any version)
- Will work with any Linux version that allows Invoke-VMScript/Copy-VMGuestFile
- Avamar Installed
- Download module here
- Unzip module, run (Dir *.psm1 | Import-Module) in Powershell
- Logged into vCenter with PowerCLI, possibly vCloud Director as well (use Get-CIVApp name | Get-CIVM | %{ $_.ToVirtualMachine() })
- Passwords specified as command line parameters with special characters have single quotes surrounding them! (chorn)
- VMware Tools are installed on the VM and scripts can be executed, and files transferred
Currently this only does Linux Agents that use RPM files. Soon to be expanded.. We do not leverage MCCLI, or any programmatic interface to Avamar during the install, so it is up to you to verify that all was installed correctly. This is solely meant to make the deployment of agents as easy as possible for VMware VMs that require guest agents.
On-Demand Install
Download the Avamar Agent to the PowerCLI System
Let’s consider this the beginning of this post and I will continue to mature and update it. For now it is limited to Linux. Very simple, the first step is to download an Avamar Agent installer file. This is available by going to the Avamar web interface and pressing the link at the bottom, Documents and Downloads. Now, find the agent that you want to install (hopefully a Linux one until I do others soon).
Another important note here is that you could leverage a simply where clause when getting VMs to find ones that match specific operating OS types and then specify the agent required to fulfill these types.
Get-VM | where {$_.ExtensionData.Guest.GuestId -eq “sles11_64Guest”}
Test Invoke-VMScript
Now we want to test to ensure you can use the credentials specified and do a simple command like “echo”. If your output looks like the screenshot, then you’re set. Another way to do the following would be to use the Get-VMScriptEcho cmdlet.
Get-VM VMname | Invoke-VMScript -GuestUser guestUser-GuestPassword guestPassword -ScriptType bash -ScriptText "echo"

Copy, Install, and Configure the Agent
Now we move on to the actual Install-AvamarAgent cmdlet. With this cmdlet we will copy the agent, as well as install and configure the agent using the specified information. The expected output is in the following screenshot. Notice that the last few lines are outputting a powershell object that contains the vm name, whether the install was successful and the result if there was an error. You can capture this in a variable such by pre-pending $tmpRun = Get-VM…
Notice how wildcards are permitted in the file name! We add a [0] at the end to ensure that we only select the first file if the wildcard matches multiple agents!
Get-VM VMname | Install-AvamarAgent -agentFile (Get-Item AvamarClient*sles11-x86_64*.rpm)[0] -GuestUser guestUser -GuestPassword guestPassword -AvamarServer avamar_ip_or_dns

How about a Avamar guest application agent? A very similar command will give similar results.
Get-VM VMname | Install-AvamarAppAgent -agentFile (Get-Item AvamarRMAN*sles11-x86_64*.rpm)[0] -GuestUser guestUser -GuestPassword guestPassword -AvamarServer avamar_name_or_ip
As you can see in the previous step we manually are specifying which agentFile. What if you want this to be determined automatically? The following command will attempt to match the proper agent file to the guest along with generating useful information which is for the most part leveraged in a planned install which is shown in the next section.
Get-VM bsg67235 | Export-VMGuestToolsInfo

Notice also from above that there are empty fields with AgentBinary_. These are leveraged in the next planned install section, but can also be leveraged here. You can fill these in on demand here if needed. Here we will replace a column, but you could also add any column as AgentBinary_name.
Get-VM name | Export-VMGuestToolsInfo | Select *,@{n=”AgentBinary_RMAN”;e={“AvamarRMAN*.rpm”}} -ExcludeProperty AgentBinary_RMAN
You can then run Get-VmGuestAvamarAgentTargets as an extra command, to ensure you have downloaded the correct guest OS agent executable. If the file is not found, you would receive a warning. The application agent file is not checked here however, so make sure it exists or else it will get skipped on install. As you can see below we are good, we have a VM, and and agent binary without warnings displayed.
Get-VM name | Export-VMGuestToolsInfo | Get-VmGuestAvamarAgentTargets

So if you want to actually install based on these results, you can call then use the Install-AvamarAgentTargeted cmdlet against your Export-VMGuestToolsInfo output.
Get-VM name | Export-VMGuestToolsInfo | Install-AvamarAgentTargeted -GuestUser username -GuestPassword password -AvamarServer avamar_dns_or_ip
Great! So what if you don’t want to specify credentials in plain text? You can leverage the next method, or you can leverage the Get-Credential cmdlet as follows.
$cred = Get-Credential

After this, you can replace the following parameters with parameters from the $cred variable when executing.
-GuestUser $cred.UserName –GuestPassword $cred.password
A Planned and Automated Multi-VM, Multi-Agent Install
- Generate CSV report with assigned Agent binaries
- Modify CSV report to include only VMs necessary for install and proper agent
- Import CSV and target VMs
- Install agents automatically
- Reporting
Now that we have the basics done and have seen it work, it is now time to step into a bit more advanced functionality. Wouldn’t it be nice if I could generate a report of the VMs that are registered and automatically choose a proper Avamar agent based on the guest ID? How about doing VMs at the same time? Let’s show you exactly how to do this.
Generate CSV Report
The following command can be run to get all of the virtual machines, and export specific metadata information that will be useful later on.
Get-Vm | Export-VMGuestToolsInfo | Export-Csv VmGuests.csv -encoding ASCII -NoTypeInformation
Modify CSV Report
Once this command is done, feel free to open the CSV file in an editor of your choice, most likely Excel. Your results should look something similar to below, notice the AgentBinary column that is auto-populated if we detected a Guest OS that is compatible with Avamar. This might not be 100% accurate, so feel free to replace the file if necessary. Remove unnecessary VMs that you don’t want targets for Agent installs. Make sure to download the agents now for any files listed that you intend to install once you save the CSV in its edited form. This CSV could be split up into multiple parts and each ran in their own PowerCLI window to parallelize the process. The whole process should take under 60 seconds, where the majority of the time can be spent transferring the agent thus relying on network bandwidth to determine total time for all VMs. You can expect under 60 seconds per VM if single threaded.

The latest version includes more columns, for guest credentials and application agent binaries. You will see the actual schema when you run the cmdlet for the first time. Application agent binaries are not linked up with appropriate versions, but if needed you can reference the displayed client binary per VM to lead you to the correct application binary. These should be downloaded individually and the name should be pasted into the appropriate columns. Each column named AgentBinary_appname that is filled with a file name will be attempted to be found and copied/installed during the process.
Import CSV and Target VMs
The next step will leverage this information to verify that the agent exists (so take the time to download them now!), guest is running, and guest id is currently detected. If all of these criteria are met then it is populated in the list below the warnings. Notice how the VMs that have agents with warnings do not show up in the list. Get-VmGuestAvamarAgentTargets acts as a filter to ensure successful install of agents. Currently, the warnings will only show for OS agents, warnings for missing application agents will be displayed during install.

Install Agents Automatically (authentication)
Ok, so the next step is to take the output from the previous step and use it to do a backup. If you are happy with what you saw above, then you can proceed with the next command.
The next thing to consider when running in batch mode is the authentication per VM. There are lots of options. Overall, keep in mind that if a guestUser is specified for a VM, then what is specified as a secure password in the CSV file takes priority (guestPasswordSecure), unsecure password next priority (guestPassword) per VM. The next section explains some of the options, other than per VM in the CSV file, you can specify a blanket default username in plain text or securely as runtime along with securely as each VM is encountered that doesn’t have previously mentioned credentials specified.
Save Usernames and Passwords in the CSV file
The Install-AvamarAgentTargeted will respect columns that are named GuestUser and GuestPassword. If these columns are filled for VMs then the credentials will be used. For this reason, the following command can be used without specifying credentials.
Import-Csv VmGuests.csv | Install-AvamarAgentTargeted -AvamarServer avamar_name_or_ip
Save Usernames and Passwords (as secure string) in CSV file
There is a column named guestPasswordSecure, which can be populated with a long secure string that is generated by New-SecurePasswordString.
New-SecurePasswordString ‘p$ssword’ | Out-File temppw.txt
Open this file with notepad, and copy the contents. The string can be pasted into the CSV file column of guestPasswordSecure for any VM. This string is only valid for the host that generated the secure string.
Specify credentials in plain text (same creds for all VMs)
Import-Csv VmGuests.csv | Install-AvamarAgentTargeted -AvamarServer avamar_name_or_ip -GuestUser guestUser -GuestPassword guestPassword
Specify credentials securely (same creds for all VMs)
Import-Csv VmGuests.csv | Install-AvamarAgentTargeted -AvamarServer avamar_name_or_ip -GuestCredentials (Get-Credential)
Prompt for credentials securely for every VM
Notice here that we are using “{“ and “}” around Get-Credential instead of parenthesis. This delays the operation from runtime, further into the script logic.
Import-Csv VmGuests.csv | Install-AvamarAgentTargeted -AvamarServer avamar_name_or_ip -GuestCredentials {Get-Credential}
So plenty of options for authentication! My suggested route would be to enter the credentials securely into the CSV file (generate the proper secure strings) and then leverage the “Prompt for credentials securely for every VM” as the default in case a VM doesn’t not have credentials specified.
Reporting
If you run Install-AvamarAgentTargeted, then you will probably want to have results stored somewhere. For this we keep a variable, $global:result filled as VMs complete. At any time, if the script stops you can access this variable to see the history. I am excluding a specific column for cleaner viewing, but this one is probably important to you to see why the “Installed” column would be False.
$global:Results | select * –excludeproperty errorResult

You could also generate an HTML report with the following command.
$global:Results | ConvertTo-Html | Out-File Results.html
.\Results.html
The Cmdlets
These can be used individually for the most part with the correct parameters. Examples of how to run each cmdlet if not found in the above post, can be found in the module above the cmdlet.
Export-VMGuestToolsInfo – Generates a CSV file containing relevant guest information and an automatic mapping of guest OS type to respective Avamar binary
New-SecurePasswordString – This generates a secures string that can be pasted into the guestPasswordSecure column of a CSV file
Get-VmGuestAvamarAgentTargets – Used as a filter to ensure the Agent binary is available, the VM is powered on, and the guest state is running.
Install-AvamarAgentTargeted – Consumes the Get-VmGuestAvamarAgentTargets filter cmdlet output and instantiates install of OS and application agents
Install-AvamarAgent – Copies, Installs. and Registers the Avamar Guest OS agent
Install-AvamarAppAgent – Copies, and Installs the Avamar Guest Application agent
Get-VMScriptEcho – Tests that remote commands can be executed on a VM
Copy-AvamarAgent – Copies the specified file to the VM
New-AvamarAgentInstall – Begins the install process of the agent on the VM
Register-AvamarAgent – Registers the Avamar Guest OS agent to Avamar
Restart-AvamarAgent – Restarts the Avamar Guest OS agent
That should be it, of course there are more things that could be configured during the registration but not covered here. The next step is to verify the install under /clients, open your Avamar console and take a look!
What could be coming? Msft Server of course..