Powershell

Veeam – Powershell get Backup Proxies Information

Hello friends,

In this opportunity I will be showing you how to obtain Backup Proxy related information from powershell in a Veeam Backup & Replication infrastructure. To begin with it is necessary to establish the initial connection to the Backup Server using the “Connect-VBRServer” command. In my case the FQDN of my Backup Server is “veeam-vbr.pharmax.local”.

PS C:\Users\jocolon> Connect-VBRServer -Server veeam-vbr.pharmax.local -Credential (Get-Credential)

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
User: pharmax\administrator
Password for user pharmax\administrator: ********
PS C:\Users\jocolon> 

After connecting to the server you can use the “Get-VBRViProxy” cmdlet to identify which Backup Proxy servers are in your infrastructure.

PS C:\Users\jocolon> Get-VBRViProxy | Format-Table -Wrap -AutoSize


Name                        Type Host                        IsDisabled Description
----                        ---- ----                        ---------- -----------
veeam-lnx-px.pharmax.local  Vi   veeam-lnx-px.pharmax.local  False      Created by PHARMAX\jocolon...
VMware Backup Proxy         Vi   VEEAM-VBR.pharmax.local     False      Created by Veeam Backu...
VEEAM-VBR-02V.pharmax.local Vi   VEEAM-VBR-02V.pharmax.local False      Created by PHARMAX\jocolon ...


PS C:\Users\jocolon>

As you can see this command shows basic information about the Backup Proxy but if you want to see the complete content you can exchange the “Format-Table” command for “Format-list”.

PS C:\Users\jocolon> Get-VBRViProxy | Format-List                 

Id                : ae2cd836-9e0a-440c-9b51-089e71c16ac6
Name              : veeam-lnx-px.pharmax.local
Description       : Created by PHARMAX\jocolon at 12/28/2021 1:24 PM.
Info              : Veeam.Backup.Model.CBackupProxyInfo
HostId            : cd06c723-875d-4da3-a633-ccac571ee296 
Host              : Veeam.Backup.Core.Common.CHost       
Type              : Vi
IsDisabled        : False
Options           : Veeam.Backup.Model.CDomViProxyOptions
MaxTasksCount     : 2
UseSsl            : False
FailoverToNetwork : True
TransportMode     : Auto
ChosenVm          : 
ChassisType       : ViVirtual

Id                : 18b661c1-d9dc-4233-90a0-7e7b10dc2d09
Name              : VMware Backup Proxy
Description       : Created by Veeam Backup & Replication
Info              : Veeam.Backup.Model.CBackupProxyInfo
HostId            : 6745a759-2205-4cd2-b172-8ec8f7e60ef8
Host              : Veeam.Backup.Core.Common.CHost
Type              : Vi
IsDisabled        : False
Options           : Veeam.Backup.Model.CDomViProxyOptions
MaxTasksCount     : 2
UseSsl            : False
FailoverToNetwork : True
TransportMode     : Auto
ChosenVm          :
ChassisType       : ViVirtual

Id                : 07c6322d-8e42-4929-8015-87c002ec0838
Name              : VEEAM-VBR-02V.pharmax.local
Description       : Created by PHARMAX\jocolon at 12/22/2021 8:46 PM.
Info              : Veeam.Backup.Model.CBackupProxyInfo
HostId            : 8452413e-92ee-4461-951d-516c7cf27cec
Host              : Veeam.Backup.Core.Common.CHost
Type              : Vi
IsDisabled        : False
Options           : Veeam.Backup.Model.CDomViProxyOptions
MaxTasksCount     : 2
UseSsl            : False
FailoverToNetwork : True
TransportMode     : Auto
ChosenVm          :
ChassisType       : ViVirtual


PS C:\Users\jocolon> 

Finally, I leave you a short piece of code to better visualize the content of the Veeam Backup Proxy:

$BackupProxies = Get-VBRViProxy
$Outobj = @()
foreach ($BackupProxy in $BackupProxies) {
    $inObj = [ordered] @{
        'Name' = $BackupProxy.Name
        'Host Name' = $BackupProxy.Host.Name
        'Disabled' = $BackupProxy.IsDisabled
        'Max Tasks Count' = $BackupProxy.MaxTasksCount
        'Use Ssl' = $BackupProxy.UseSsl
        'Failover To Network' = $BackupProxy.FailoverToNetwork
        'Transport Mode' = $BackupProxy.TransportMode
        'Chassis Type' = $BackupProxy.ChassisType
        'OS Type' = $BackupProxy.Host.Type
        'Services Credential' = $BackupProxy.Host.ProxyServicesCreds.Name
        'Status' = Switch (($BackupProxy.Host).IsUnavailable) {
            'False' {'Available'}
            'True' {'Unavailable'}
            default {($BackupProxy.Host).IsUnavailable}
        }
    }
    $OutObj += [pscustomobject]$inobj
}
$OutObj | Format-Table -Wrap -AutoSize

Here is the output of the resulting code.

Hasta Luego Amigos!

Veeam – Powershell Module Introduction

Hello to everyone,

This time I will be showing an introduction of the Veeam Powershell module and how to make the initial connection to the backup server. In Veeam Backup & Replication version 11 a new powershell module called “Veeam.Backup.PowerShell” was introduced. According to the Veeam documentation portal there are two ways to use this powershell module:

  1. Accessing Powershell from the Veeam Backup & Replication console.
  1. Importing the module from a traditional Powershell console.
PS C:\Users\jocolon> Import-Module -Name Veeam.Backup.PowerShell

WARNING: The names of some imported commands from the module 'Veeam.Backup.PowerShell' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
PS C:\Users\jocolon> 

It is important to mention that the Powershell module is available on the Veeam Backup server or on any device where the management console is installed. Reference:

The remote machine from which you run Veeam PowerShell commands must have the Veeam Backup & Replication Console installed. After you install the Veeam Backup & Replication Console, Veeam PowerShell module will be installed by default

Veeam PowerShell Reference

To validate if the module was loaded successfully you can use the “Get-Module” command. As you can see in the example version 1.0 of “Veeam.Backup.PowerShell” was loaded on the system.

PS C:\Users\jocolon> Get-Module -ListAvailable -Name Veeam.Backup.PowerShell



    Directory: C:\Program Files\Veeam\Backup and Replication\Console


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0        Veeam.Backup.PowerShell             {Get-VBRComputerFileProxyServer, New-VBRSanI


PS C:\Users\jocolon>

Speaking a bit of history, the traditional way to load the Powershell module in pre-V11 versions was to use the following command:

 Add-PSSnapin -Name VeeamPSSnapIn #Veeam Powershell Pre11

Now in Veeam VBR version 11 the traditional “Import-Module” command is used like any other Powershell module. In the case of Veeam 11 we use the command referring to the module called “Veeam.Backup.PowerShell”. Once the module is loaded you can verify which cmdlets are available with the “Get-Command” cmdlet.

PS C:\Users\jocolon> Get-Command -Module Veeam.Backup.PowerShell


CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           Add-VBRCloudTenantToTapeJob                        1.0        Veeam.Backup.PowerShell
Alias           Add-VBRHPSnapshot                                  1.0        Veeam.Backup.PowerShell
Alias           Add-VBRHPStorage                                   1.0        Veeam.Backup.PowerShell
Alias           Clone-VBRJob                                       1.0        Veeam.Backup.PowerShell
Alias           Get-VBRHPCluster                                   1.0        Veeam.Backup.PowerShell
Alias           Get-VBRHPSnapshot                                  1.0        Veeam.Backup.PowerShell
Alias           Get-VBRHPStorage                                   1.0        Veeam.Backup.PowerShell
Alias           Get-VBRHPVolume                                    1.0        Veeam.Backup.PowerShell
Alias           Remove-VBRHPSnapshot                               1.0        Veeam.Backup.PowerShell
Alias           Remove-VBRHPStorage                                1.0        Veeam.Backup.PowerShell
Alias           Set-VBRCloudTenantToTapeJob                        1.0        Veeam.Backup.PowerShell
Truncated.......
PS C:\Users\jocolon>

Now that everything is ready you can establish the initial connection to your Backup server. To accomplish this process use the command “Connect-VBRServer”. In the following example we use the option to request credentials but Veeam modules accept traditional methods to provide credentials in Powershell (Referencias).

PS C:\Users\jocolon> Connect-VBRServer -Server veeam-vbr.pharmax.local -Credential (Get-Credential)

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
User: pharmax\veeam_admin
Password for user pharmax\veeam_admin: ********
PS C:\Users\jocolon> 

In this example I connect to the server with the name “veeam-vbr.pharmax.local” with the username “pharmax\veeam_admin”. It is important to mention that only users with the “Veeam Backup Administrator” role can establish connection via powershell. If you try to connect with an account that does not have this privilege level, you will get the following error:

PS C:\Users\jocolon> Connect-VBRServer -Server veeam-vbr.pharmax.local -Credential (Get-Credential)

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
User: pharmax\vrauser
Password for user pharmax\vrauser: ********
Connect-VBRServer : Only users with Veeam Backup Administrator role assigned can use Veeam Backup PowerShell Snap-in
At line:1 char:1
+ Connect-VBRServer -Server veeam-vbr.pharmax.local -Credential (Get-Cr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Connect-VBRServer], Exception
    + FullyQualifiedErrorId : AccessCheckerErrorId,Veeam.Backup.PowerShell.Cmdlets.ConnectVBRServer

PS C:\Users\jocolon> 

To validate existing sessions use the command “Get-VBRServerSession”. The following example shows the connection to the “veeam-vbr” server using the “veeam_admin” user.

PS C:\Users\jocolon> Get-VBRServerSession                 


User        Server                  Port
----        ------                  ----
veeam_admin veeam-vbr.pharmax.local 9392


PS C:\Users\jocolon>

Once connected to the Veeam server you can run any cmdlet to extract the required information. As an example I will show you the backup tasks that are created on my Veeam test server.

PS C:\Users\jocolon> Get-VBRJob

WARNING: This cmdlet is no longer supported for computer backup jobs. Use "Get-VBRComputerBackupJob" instead.

Job Name                  Type            State      Last Result  Description
--------                  ----            -----      -----------  -----------
Server With Netapp LUN... Windows Agen... Stopped    None         Created by PHARMAX\administrator
HyperV-Backup-Job         Hyper-V Backup  Stopped    None         Created by PHARMAX\administrator 
WIN HyperV VM Backup      Hyper-V Backup  Stopped    Success      Created by PHARMAX\jocolon
PHARMAX-HQ-SVR            VMware Backup   Stopped    None         Created by PHARMAX\administrator
SOBR - TEST               VMware Backup   Stopped    None         Created by PHARMAX\administrator
COMP-CLUSTER-NFS          VMware Backup   Stopped    None         Created by PHARMAX\administrator 
HPE-StoreOnce-Copy-Job    VMware Backu... Stopped    Success      Created by PHARMAX\administrator
VM - Test - AWS           VMware Backup   Stopped    Failed       Created by PHARMAX\jocolon

PS C:\Users\jocolon> 

I hope this information is helpful. If you have any doubts or questions about this post, leave them in the comments. Hasta Luego Amigos!