Hello all,
I learned something recently that I thought worth sharing. I have been testing in-guest scripting in Veeam Availability Orchestrator (VAO). This is the cool scripting that is executed inside a VM during a test or failover - yet centrally managed in the VAO console. I have a simple script that creates a file and updates the date / time inside the file as part of my testing.
BTW, the script looks like this:
########### #Michael White - 11/22/17 # # # script to create a file and put the date in it. Testing from within VAO. # # v1.0 $A = Get-Date; Add-Content c:\utils\vao_log.txt "$A - test recording date. "
When this is script is executed you see the following in the UI.
We can see the script executed fine. If there is a problem during script execution we can see something of the problem. For example:
What I learned is how to pull more info from the script into the UI (and history reports to). Notice the updated code.
########### #Michael White - 11/22/17 # # # script to create a file and put the date in it. Testing from within VAO. # Added some logic to add info to VAO logs. # # v1.1 try { $A = Get-Date; Add-Content c:\utils\vao_log.txt "$A - test recording date. " Write-Host "file written and updated with date / time" } Catch { Write-Error " something didn't work - error" Write-Error $_.Exception.Message }
The existing script has try { …..} put around it, and then the Catch section is added. BTW, we see Write-Error in the example above but Write-Warning is also useful. Now what we see in the UI is a little different.
See the extra info? There could be more by adding more Write-Host lines. Check out the report info below.
If a error occurs, there will be different info seen. So pretty handy.This is just a hint of the power that can be in your scripts that are used by VAO.
I think that it is very cool that a PowerShell script unaltered can work in-guest with VAO but yet can be improved if necessary.
BTW, something to remember - when you add a script to VAO - in 1.0 it is Powershell only - it is set by default to execute only during a real failover. Hopefully we will get that changed to execute during a real failover and a test. But when you add a script make sure that check that it executes when you want it to, and has the necessary credentials assigned.
Update:
- 2/26/18 - This works fine with the GA build.
- 2/26/18 - You need to have PowerShell 3.0 or later (and .Net Framework 4.0) inside the VM that is going to execute the script. If you don’t you will see a very specific error - “Cannot find the type for custom attribute ‘Parameter’. Make sure that the assembly that contains this type is loaded”.
- 12/2/17 - added the comment about default behaviors.
Questions or comments?
Michael
=== END ===