Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions VB365-KB4821/Find-MultipleBackupApplications.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,20 @@ foreach ($org in $orgs) {

# check if multiple backup applications are used
Write-Verbose "Backup Applications found: $($apps.Count)"
if ($apps.Count -gt 1) {
if ($apps.Count -gt 0) {
# adding field to show if backup application was removed
$apps | Add-Member -MemberType NoteProperty -Name "RemovedFromVeeam" -Value $false

# remove extra backup applications if the Fix flag is set
if ($Fix) {
Write-Verbose "Fix flag is set. Removing multiple backup applications for organization $($org.Name)..."
# $j = 1 skipping first backup application
$appsToRemove = $apps | Select-Object -Skip 1
foreach ($app in $appsToRemove) {
foreach ($app in $apps) {
Write-Verbose "Removing backup application $($app.ApplicationId)"
Remove-VBOBackupApplication -Organization $org -BackupApplication $app -Confirm:$false
Remove-VBOBackupApplication -Organization $org -BackupApplication $app -Confirm:$false | Out-Null

# noting that application was removed in output
$app.RemovedFromVeeam = $true
}
Clear-Variable -Name appsToRemove
}

$object = [PSCustomObject] @{
Expand All @@ -115,10 +112,6 @@ foreach ($org in $orgs) {
Clear-Variable -Name apps
}

if ($output.Count -eq 0) {
Write-Verbose "No organizations with multiple backup applications found. Moving along..."
}

# logging out of Veeam session
Disconnect-VBOServer

Expand Down