Summary
Another powerful PowerShell script that leverages Veeam Backup & Replication to simplify the process of restoring virtual machines. With this script, you can perform staged VM restores. The script automates the entire process, from connecting to the Veeam server and listing available restore points to selecting a restore point and initiating the restore process.
The script
Download here
The script is highly customizable and utilizes several parameters to tailor the restore process to your specific needs. Let's take a closer look at these parameters:
ESXiServer: Specify the name of the target ESXi server where the VM will be restored. This allows you to choose the appropriate destination for the restore operation.
VMName: Provide the name of the VM that you want to restore. This ensures that the script locates the correct VM during the restore process.
Jobname: Enter the name of the Veeam backup job that contains the VM you wish to restore. This parameter helps the script identify the appropriate backup source.
VirtualLab: Specify the name of the virtual lab to be used for staging the VM restore. The virtual lab creates an isolated environment for testing and preparing the restored VM before its final deployment.
StagingScript: Supply the path to the script that will be executed during the staging process. This allows you to automate additional actions or configurations as part of the restore workflow.
Credentials: Specify the name of the configured credentials used for executing the staging script. This ensures secure and authorized access during the restore process.
In addition to the customizable parameters, the PowerShell script introduces the $startupOptions
variable, which allows you to fine-tune the startup behavior of the restored VM. These values ensure optimal performance and responsiveness during the restore process.
The $startupOptions
variable is set using the New-VBRApplicationGroupStartupOptions cmdlet with the following values:
MaximumBootTime: This parameter defines the maximum time (in seconds) allowed for the VM to boot up completely.
ApplicationInitializationTimeout: This parameter specifies the time (in seconds) allocated for the VM to initialize its applications and services.
MemoryAllocationPercent: This parameter determines the percentage of memory allocated to the restored VM.
By configuring these values appropriately, you can control the startup behavior of the restored VM
Sample Staging Script
The WinAVDeepScan.ps1 script automates the Windows http proxy configuration (remember to configure your Virtual Lab accordingly) and virus scanning on Windows systems using Windows Defender.
The script begins by retrieving the default gateway IP address. It then proceeds to configure the proxy settings by enabling the proxy and setting the proxy server to the default gateway IP address with a specified port (8080). This can be useful if you want to upgrade to a newer AV signature pattern or download anything else from the internet.
Also, the script triggers Windows Defender for a real-time (Full) virus scan. It detects the latest version of Windows Defender and initiates a scan using the MpCmdRun.exe utility. The output of the scan is checked for the presence of a certain string that indicates threat detection.
The stage is yours! Happy Weekend!