forked from VeeamHub/powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-VMandDiskFilterDetails.ps1
64 lines (47 loc) · 1.7 KB
/
Get-VMandDiskFilterDetails.ps1
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#Requires -Version 4
#Requires -RunAsAdministrator
<#
.Synopsis
Simple Veeam report to export details about VM job objects and their disk mode & filters
.Notes
Version: 0.2
Author: Joe Houghes
Modified Date: 3-5-2021
.EXAMPLE
Get-VMandDiskFilterDetails | Format-Table
.EXAMPLE
Get-VMandDiskFilterDetails | Export-Csv VM_DiskFilterDetails.csv -NoTypeInformation
#>
function Get-VMandDiskFilterDetails {
[CmdletBinding()]
param ()
begin {}
process {
$ReportJobs = Get-VBRJob | Where-Object { $PSItem.JobType -eq 'Backup' -OR $PSItem.JobType -eq 'BackupSync' -AND $PSItem.BackupPlatform.Platform -eq 'EVmware' }
$Repositories = Get-VBRBackupRepository | Select-Object Name, Id
$reportJobOutput = foreach ($CurrentJob in $ReportJobs) {
$CurrentBackup = Get-VBRBackup -Name $CurrentJob.Name
$CurrentRepo = $Repositories | Where-Object -Property Id -EQ -Value $CurrentBackup.RepositoryId
$CurrentJobVMs = $CurrentJob.GetViOijs()
$reportVMOutput = foreach ($CurrentVM in $CurrentJobVMs) {
$DiskMode = $CurrentVM.DiskFilterInfo.Mode
$DisksSpecific = switch ($DiskMode) {
AllDisks { 'AllDisks' }
default { ($CurrentVM.DiskFilter.Disks | Select-Object -ExpandProperty DisplayName) -join '; ' }
}
[pscustomobject] @{
'BackupJob' = $CurrentJob.Name
'VMName' = $CurrentVM.Name
'Location' = $CurrentRepo.Name
'DiskMode' = $DiskMode
'DisksSpecific' = $DisksSpecific
}
} #end foreach CurrentVM
$reportVMOutput
} #end foreach CurrentJob
}
end {
if ($Disconnect) { Disconnect-VBRServer }
$reportJobOutput
}
}