PowerShell script exchange
Post Reply
manuel.aigner
Enthusiast
Posts: 41
Liked: 6 times
Joined: Sep 25, 2017 8:25 am
Full Name: Manuel Aigner
Contact:

How to remove a VBRAzureComputeProxyAppliance from Repo Config?

Post by manuel.aigner »

Hi There,

ATM I'm developing a script to mass implement Azure Proxy Appliance (for health checking).
My problem is, I already have configured an appliance from UI. Therefore I can't use this machine to test my script.
How is it possible to remove this existing configuration, without completely destroy the rest of the repo config?
I can't find any way. Neither in B&R Console nor via powershell.
david.domask
Product Manager
Posts: 3476
Liked: 835 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to remove a VBRAzureComputeProxyAppliance from Repo Config?

Post by david.domask »

Hi Manuel,

Just to confirm, you're talking about this component here, correct?

The cmdlets for Azure Object Storage Repositories are found here, and you can make a new appliance with New-VBRAzureComputeProxyAppliance and then set with Set-VBRAzureBlobRepository
David Domask | Product Management: Principal Analyst
manuel.aigner
Enthusiast
Posts: 41
Liked: 6 times
Joined: Sep 25, 2017 8:25 am
Full Name: Manuel Aigner
Contact:

Re: How to remove a VBRAzureComputeProxyAppliance from Repo Config?

Post by manuel.aigner »

Exactly what I mean.
Ok, am I right, that I can overwrite the configuration with a new one, but it's not possible to remove an existing one?
david.domask
Product Manager
Posts: 3476
Liked: 835 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to remove a VBRAzureComputeProxyAppliance from Repo Config?

Post by david.domask »

Correct, you can overwrite, but you're not able to remove it currently, same as within the UI.

As a workaround, you could remove the old repository and re-add it with the same specs -- any backups in the repository will be imported during the rescan after adding the repository.
David Domask | Product Management: Principal Analyst
manuel.aigner
Enthusiast
Posts: 41
Liked: 6 times
Joined: Sep 25, 2017 8:25 am
Full Name: Manuel Aigner
Contact:

Re: How to remove a VBRAzureComputeProxyAppliance from Repo Config?

Post by manuel.aigner »

Ok... it's also hard to find out if a repository has already a proper helper appliance configuration. There seems to be no way to get this information via powershell module from veeam.
My workaround ist to fetch this directly via VeeamBackup DB.
It's essential for me, as I don't want to reconfigure already configured repos by default. (saving time)

Code: Select all

 $repoOptionsXml = (Invoke-Sqlcmd -Query "SELECT [options] FROM [dbo].[BackupRepositoriesView] WHERE [name] = '$($repo.Name -replace "'","''")'" -Database 'VeeamBackup' -ErrorAction Stop).options
            if ($repoOptionsXml) {
                $repoXml = [xml]$repoOptionsXml
                $vmTemplate = $repoXml.SelectSingleNode('//ArchiveRepositoryOptions/VmTemplate')
                # Appliance gilt als konfiguriert, wenn SubscriptionId keine Null-GUID ist
                $applianceConfigured = $vmTemplate -and
                    $vmTemplate.SubscriptionId -and
                    $vmTemplate.SubscriptionId -ne '00000000-0000-0000-0000-000000000000'
                if ($applianceConfigured) {
                    if (-not $Force) {
                        Write-CSDLog -LogText "Repository '$($repo.Name)' hat bereits eine Helper Appliance konfiguriert (VmSize: $($vmTemplate.VmSize), RG: $($vmTemplate.ResourceGroup)). Übersprungen (verwende -Force zum Überschreiben)." -Severity I
                        continue
                    }
                    Write-CSDLog -LogText "Repository '$($repo.Name)' hat bereits eine Helper Appliance (VmSize: $($vmTemplate.VmSize), RG: $($vmTemplate.ResourceGroup)) - wird durch -Force überschrieben." -Severity W
                }
            }

david.domask
Product Manager
Posts: 3476
Liked: 835 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to remove a VBRAzureComputeProxyAppliance from Repo Config?

Post by david.domask »

Thanks for sharing your script, though please note that querying the database directly is both unsupported and not recommended.

I can give you still unsupported methods with PowerShell that should give you less troubles (querying DB directly typically encounters and sometimes causes unexpected issues):

Code: Select all

$objStgRepo = Get-VBRObjectStorageRepository -Name 'name of repo'
$fullRepo = [Veeam.Backup.Core.CBackupRepository]::Find($objStgRepo.id)
$helperApplianceOptions = [xml]$fullRepo.ArchiveRepository.info.Options
$helperApplianceOptions.ArchiveRepositoryOptions.VmTemplate.SubscriptionId

#Check $helperApplianceOptions.ArchiveRepository.VmTemplate.SubscriptionId == 00000000-0000-0000-0000-000000000000 ? No Helper Appliance Configured, else there is an appliance configured
It will give you same access in a much nicer XML object in powershell to work with, and you will be able to pull the data like you're doing with the SQL query.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests