A colleague wrote a short, but informative post for a corporate blog, which today is offered to your attention (it would be more correct to call it “the author’s Russian-language version, with changes and additions”).
Good afternoon,
My name is Vladimir Eremin, I work for Veeam Software as a product manager. One of the areas entrusted to me is PowerShell equipment for our product Veeam Backup and Replication, and it is about working with it that will be discussed further.

')
Let's start with a small lyrical digression.
In the course of my work, I repeatedly encountered the opinion that scripts and everything connected with them are a lot of hardcore bearded men, and, as the character of a famous cartoon said, it’s better not to touch them with a ten-meter stick. In reality, as is usually the case, everything looks somewhat different.
With proper skill, knowledge of PowerShell makes life much easier - you take a task that could potentially take the N-th number of hours to complete, and, thanks to automation, reduce it to a few minutes. You get rid of your beloved from the routine, you prevent the human error factor, in addition, you learn everything new and previously unknown in the process of writing scripts. Do not forget that the work with the same Nano Server will be built exclusively through PowerShell. Therefore, friends, if you have not studied PowerShell before, I strongly recommend starting to learn it right now.
Free does not mean bad
Like every self-respecting software company, we have our own flagship product, in our case, the well-known and beloved Veeam Backup & Replication. So that no one leaves offended, it is released in several versions, ranging from Free to Enterprise Plus.
The main feature that the free version boasts is the simplified backup function called VeeamZIP.
Despite its simplicity and convenience, VeeamZIP had one annoying detail that made users shed mean and not so much tears on our forums again and again, namely, the inability to create backups on a schedule.
Everything changed when, with the release of Veeam Backup & Replication v8 Update 2, we gave a few PowerShell cmdlets to the public. Using them, the user was able to write a simple script with which the backup of one or several machines was created. In addition, thanks to Task Scheduler, the script could set any desired schedule.
It is great understanding that for some users the combination of the words “simple” and “script” looks a bit strange, I wrote a small example (you can download it
here and
here ). Below we analyze it in a little more detail.
From words to deeds. Options
As mentioned earlier, the script allows you to create backups of selected virtual machines. Machines can be located on regular hosts / clusters, as well as those managed by vCenter (yes, an example for VMware was chosen as an analysis).
The script has three required parameters: the names of the virtual computers, the hosts / clusters / vCenter on which they sit, and the folder into which the backups will be relied.
The remaining parameters are optional.
##################################################################
# ,
##################################################################
# . ( ). , $VMNames = “VM1”,”VM2”
$VMNames = ""
# vCenter , , ( )
$HostName = ""
# . , C:\Backup ( )
$Directory = ""
Depending on desires and preferences, you can change the level of compression, the time during which the backup should be stored, the settings of VMware Quiescence, as well as the notification options:
# (; : 0 – ., 4 – , 5 - , 6 - , 9 - )
$CompressionLevel = "5"
# VMware Tools Quiescence. «» (; VMware Tools. : $True/$False)
$EnableQuiescence = $True
# (; , VeeamZIP , .
# : Never, Tonight, TomorrowNight, In3days, In1Week, In2Weeks, In1Month)
$Retention = "Never"
If there is a need to receive a report on the work done, you can play around with the notification settings:
##################################################################
#
##################################################################
# ()
$EnableNotification = $True
# SMTP
$SMTPServer = ""
#
$EmailFrom = ""
#
$EmailTo = ""
#
$EmailSubject = ""
The report is as follows:

Experimenting with the values of variables, you can find the combination that will satisfy exactly your idea of the beautiful. For example, if you want backups to be deleted after two weeks, set the
$ Retention variable to “In2Weeks” and so on.
In order to heighten convenience, I provided the variables in the script with a brief description, so there is no urgent need to describe each setting separately and its possible values, in my opinion.
Schedule. Reliable, like a Swiss watch
Before you put the execution of the script on the stream, I advise you to make sure that you are fine with it by running it a couple of times manually.
The easiest way I know how to run scripts on a schedule is the Windows Task Scheduler.
Open it and proceed to the creation of the Basic Task.

We do not forget that it is not bad to supply tasks with meaningful names and descriptions, so as not to waste precious time, wondering what it is being done, and most importantly - for what purpose.
The next page is Task Trigger.
Everything is simple and intuitive. We need to decide how often we would like to create backups (in English for this case there is a smart abbreviation - RPO, Recovery Point Objective), and to reflect our desires in the form of specified settings.
The most common option is to create a backup once a day.

Next, set the runtime of the script. To avoid unnecessary server workload during business hours, evening hours are often chosen.

On the next page, we indicate the launch of the program as a necessary action and follow on.

In the appropriate field enter the following command:
Powershell –file “ Veeamzip.ps1”

Well that's all! If you suddenly remembered that you need to make some changes to the newly created task, then check the
“Open the Properties” box before clicking
“Finish” .

There is a serious suspicion that in the overwhelming majority of cases the script will be executed on the server at a time when the responsible user is not logged in at all. In this connection, it is recommended to specify a username and password, which will allow the script to do its dirty work without a user login in the system.

Since we are people suspicious, it will not be superfluous after creating a task, right-click on it and run it in test mode. (“Run”)
Instead of an afterword
Our exciting journey to the world of scripts can be considered complete. The long-awaited goal (scheduled backups) has been achieved, and interest in PowerShell is awake, at least I sincerely hope so. Feel free to contact us both here and on our forums (
forums.veeam.com ) for
any questions you may have .
See you again!
useful links