When you have multiple jobs with many VMs it’s a boring task to change all the disk exclusions by hand. That’s why VEEAM have made a nice PowerShell module to automate this boring tasks.
Excluded disks are displayed with numbers, the numbers in Hyper-V are different (because of the IDE disks) then how the numbers are showed in VMWare.
Since Veeam 9.5 Update 4 the diskfilter mechanism in Veeam is changed.
Now we can report both.. SCSI Controller id and the Keynumber as we known earlier.
This means the PowerShell CMDLets also Changed.
Report diskfilter:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#Load VEEAM PowerShell Module Add-PSSnapin "VeeamPSSnapIn" -ErrorAction SilentlyContinue #Get all VEEAM Diskfilter data $jobs = get-vbrjob $data = @() foreach ($job in $jobs) { $data += $job | Get-VBRJobObject | select name, @{label="Diskfilter";expression={$_.diskfilter.disks}} } #Export to CSV $data | export-csv C:\DiskExclusion.csv |
Change diskfilter:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
Add-PSSnapin "VeeamPSSnapIn" -ErrorAction SilentlyContinue $job = get-vbrjob -Name "TST" $jobobjects = $job.GetObjectsInJob() Foreach($jobobject in $jobobjects){ $DiskArray = @() $DKeys = "2000","2001","3000","3001" foreach($Dkey in $Dkeys){ $VDiskKey = [Veeam.Backup.Model.VDiskKey]::New($DKey) $DiskArray += [Veeam.Backup.Model.CDiskKeyInfo]::CreateDiskInfo($VDiskKey) } $CDiskFilterInfo = [Veeam.Backup.Model.CDiskFilterInfo]::CreateSelectedDisks($DiskArray) $VSSOptions = $jobobject.vssoptions $JobInfoType = $jobobject.info.Type $jobobject.Update($VSSOptions,$CDiskFilterInfo,$true,$JobInfoType) } |
Change diskfilter before 9.5 Update 4
See the current excluded disks and the numbers with this script (Run as Administrator):
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#Load VEEAM PowerShell Module Add-PSSnapin "VeeamPSSnapIn" -ErrorAction SilentlyContinue #Get all VEEAM Diskfilter data $jobs = get-vbrjob $data = @() foreach ($job in $jobs) { $data += $job | Get-VBRJobObject | select name, diskfilter } #Export to CSV $data | export-csv C:\DiskExclusion.csv |
Change the disks exclusions with PowerShell (Run as Administrator):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#Load VEEAM Powershell module Add-PSSnapin "VeeamPSSnapIn" -ErrorAction SilentlyContinue #Get all objects in VEEAM Back-up job $objects = Get-VBRJob -name "TEST" | Get-VBRJobObject #$a is the default parameter #$b are the SCSI IDs in number format $a = "Verb8|" $b = "2000;2001;2002;2003" $disks = $a + $b #Change the disk exclusion for each object in the job Foreach($o in $objects){ $objInfo = $o.info $objInfo.diskFilter = $disks [Veeam.Backup.Core.CObjectInJob]::Update($objInfo) $locatie = $o.Name Write-host "Back-up diskconfig changed on VM: $locatie" } |
Comments are welcome.
Nice scripts. You also have a script to see the current excluded disks on all VM’s and export to .csv for 9.5 Update 4 and higher?
When I run the pre 9.5u4 script I get this as .csv output:
#TYPE Selected.Veeam.Backup.Core.CObjectInJob
Name,”DiskFilter”
SRV0032,”Veeam.Backup.Core.CDiskFilter”
SRV0050,”Veeam.Backup.Core.CDiskFilter”
SRV0056,”Veeam.Backup.Core.CDiskFilter”
SRV0117,”Veeam.Backup.Core.CDiskFilter”
SRV0120,”Veeam.Backup.Core.CDiskFilter”
Thx in advance,
Ali
Hello Ali,
You need to expand the diskfilter object.
A way to do this is with a expression like: select name, @{label=”Diskfilter”;expression={$_.diskfilter.disks}}
So you can go deeper in the object this way: $_.diskfilter.disks.keys
Hope this helped.
Updated the code 🙂
Hello Rob. Do you have any advise on how to explore the undocumented Veeam Powershell object model? I have a use case for example where I need to delete restore point files from a repository, my hunch is that there is either static or instance methods to do this, but am not sure where to look.
Hello Eugene,
Never did that before. But the Remove-VBRRestorePoint is not suitable?
What are you trying to archive? There are a lot of methods available with the “get-vbrrestorepoint | gm” commandlet..
Greetings,
Rob
Yes I wasn’t able to get anyone on forums.veeam.com to suggest how, but I need to delete the file which stores a restore point. It is on a repository of a deduplication appliance which does not have any methods for interacting with the items in the deduplication appliance. Veeam can interact with these files via the Files pane. But I have thousands of files to delete, and am still searching.
The objects returned from get-vbrrestorepoint do have delete() methods, but a forum member told me this is “delete from configuration database” where what i need is to delete the file. I can get the file name and metadata of a restore point with the .findStorage() method of an object returned by get-vbrrestore point. I feel so close 🙂
Besides the DiskFilter property of VBRJobObject there is still a DiskFilter in the Info property of VBRJobObject, which also has a setter.
However, the content is now an XML structure. The easiest way is to read Info.DiskFilter of an existing job with the corresponding configuration and then have a correct XML structure that can be stored or used as string to update other job objects.
Updating is done the same way as before 9.5 Update 4
Tested with Veeam B&R 12