Veeam Backup & Restore is, as said before, a great package to use for backups in virtual environments. But the most important part of backups is to be able to restore! A great feature of Veeam Backup & Restore is, if you have the correct license, the SureBackup functionality with which you can check if the backups would run if restored. The basic checks available within Veeam Backup and Restore would cover a lot but what if you would like to go deeper? For instance, if you would like to check if the Active Directory server would reply on a query? Or, if you would want to know if data on a share is readable. For this you can create your own SureBackups checks!

In my case I would like to query the Active Directory server for a specific user and see if it exists, but you don't want the user hard-coded in the script but add it to the SureBackup check. I create a batch file in the directory '%ProgramFiles%\Veeam\Backup and Replication\Backup' woth the name Query-ADuser.bat:

@echo off
powershell.exe -noninteractive -noprofile -command "& {%SureBackup%\Query-ADUser.ps1 %1 %2 } -ExecutionPolicy RemoteSigned"
exit /b %errorlevel%

The powershell script mentioned contains the following code:

# Query-ADUser.ps1
[string] $DomainController,
[string] $UserName
$result = [bool] (Get-ADUser -Filter { SamAccountName -eq $UserName } -Server $DomainController -ErrorAction SilentlyContinue)

if( $Result -eq $False)
write-host ("Error 1, User '" + $UserName + "' does not exist or is not found.")

Be sure you put the Powershell script in the location mentioned in the batchfile! The last file to create is the file QueryADUser.xml in the directory '%ProgramFiles%\Veeam\Backup and Replication\Backup\SbRoles'. It can be a copy of another file from thet directory, but make sure to alter the Id (should be unique among the other files), Name (twice) and TestScriptFilePath (te reflect the location and name of the batch file):

<?xml version="1.0" encoding="utf-8" ?>
<Name>Query AD Account</Name>
<Name>Query AD Account</Name>
<TestScriptFilePath>%ProgramFiles%\Veeam\Backup and Replication\Backup\Query-ADUser.bat</TestScriptFilePath>
<Arguments>%vm_ip% UserName</Arguments>

After these three steps you should be able to add the Query AD Account check to your Veeam SureBackup job!

No comments

Add Comment

Standard emoticons like :-) and ;-) are converted to images.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.