I'm trying to generate a list of all proxy servers attached to veeam but I'm running into some issues.
There doesn't seam to be a command to `Get-VBRproxies` for a given server. I just want to list out all of the proxy information like it is on the backup proxies tab inside of the VBR software. So VMWare, Agent, HyperV, and CDP Proxies. So far as i can tell theres not a command-let to grab agent proxies but rather i have to query it by the individual job. This is what i have so far...
Get-VBRComputerFileProxyServer
Id Description Server ConcurrentTaskNumber
-- ----------- ------ --------------------
2df7b4a9-e230-4bc7-97a6-db... Created by Veeam Backup & ... Veeam.Backup.Core.Common.C... 2
5a7c25b9-87cb-41e3-bb1b-81... Created by Powershell at 8... Veeam.Backup.Core.Common.C...
Why is the fact that it returns the PSCompterName completely omitted?
Interesting. On both my v11 (11.0.1.1261) and beta2 v12 (12.0.0.817) I'm not seeing PSComputerName returned. Had to track down the name via Get-VBRServer like -
To get the server name of the proxy don't you think thats a bit convoluted?
If there are multiple servers which there likely are with proxies, I would have to make another custom object and dump this to a table. This should definitely be improved...
Yes I agree that it would be handier if Get-VBRComputerFileProxyServer returned the friendly name as well as the hostname but if memory serves they're the same value for all manually added proxies
TBH I'm not sure why they return a CHost object here, but I can think of some reasons I might want that in a script to avoid having to do another Get-VBRServer lookup and just have the CHost right there, as the Get-VBRServer lookup can be expensive in larger environments.
David Domask | Product Management: Principal Analyst
I Just think it would be much simpler if it just returned the proxy server information and all the values associated with it. Its something that I can get in 2 clicks in the web interface which makes me think for the sake of automation it would be much easier. In fact its much easier just to grab this information straight from the actual veeam db itself.
<# PROXY Server Finder 9000
This script will return text files of proxy servers found from a list of VBRs Assigned to a variable.
unable to find proxies for VBRS using local SQL express databases.
MUST BE RAN WITH A SERVICE ACCOUNT
#>
#newline variable
$OFS = "`n"
#path to log file
$fileName = 'C:\Scripts\results\proxies.txt'
#path to another log file lol
$filePathList = 'C:\Scripts\results\proxielist.txt'
#registry path
$VeeamRegPath = 'HKLM:\SOFTWARE\Veeam\Veeam Backup and Replication\'
#list of VBRS
$VBRServers =
"vbr1.contoso.local",
"vbr2.contoso.local"
#If log file already exists, delete it.
if (test-path -Path $fileName) {
Remove-Item -Path $fileName
}
if (test-path -Path $filePathList) {
Remove-Item -Path $filePathList
}
#iterate thru each server in list
ForEach ($VBR in $VBRServers) {
#isettting our variables to null so they are empty at the start of each loop
$results = $null
$SQLServerName = $null
$SQLDatabaseName = $null
$serviceCheck = $null
$sesh = $null
#create ps session with server
$sesh = New-PSSession -ComputerName $VBR -ErrorAction SilentlyContinue
# if no connection can be made, move on to next server
if ($null -eq $sesh) {
write-host "Unable to create session with $VBR, moving on." -ForegroundColor Yellow
continue
}
#check to see if veeam is installed, if not move on to next server
$serviceCheck = Invoke-Command -Session $sesh -ScriptBlock { get-service -DisplayName "veeam backup service" -ErrorAction SilentlyContinue }
if ($null -eq $serviceCheck) {
$outString = "$VBR does not have Veeam installed.."
Write-Host $outString -ForegroundColor Magenta
Add-Content -Value $outString -Path $fileName
Add-Content -Value $OFS -Path $fileName
continue
} else {
write-host "$VBR has veeam installed." -ForegroundColor Cyan
}
#grab SQL servers name from VBR servers registry
$SQLServerName = Invoke-Command -Session $sesh -ScriptBlock {
Get-ItemPropertyValue -path $VeeamRegPath -Name SqlServerName } -ErrorAction Ignore
#if there is no entry for sql server, probable postgresql is being used, move on to next server
if ($null -eq $SQLServerName) {
$outString = "$VBR has no SQL installation, possible Postgresql"
write-host $outString -ForegroundColor Magenta
Add-Content -Value $outString -Path $fileName
Add-Content -Value $OFS -Path $fileName
continue
}
<#test for SQL express.. if the sql servers name does not have any of the following domain names, than its the VBR itself
and does not have the domain name attached to the end.move on to next server #>
if ($SQLServerName -notlike "*.dev.contoso.local" -and $SQLServerName -notlike "*.test.contoso.local" -and $SQLServerName -notlike "*.lab.contoso.local" -and $SQLServerName -notlike "*.preprod.contoso.local") {
$Outstring = "$VBR is using SQL Express, unable to pull proxies."
Write-Host $outString -ForegroundColor Magenta
Add-Content -value $outString -Path $fileName
Add-Content -Value $OFS -Path $fileName
continue
}
#Grab database name from VBR server registry
$SQLDatabaseName = Invoke-Command -Session $sesh -ScriptBlock {
Get-ItemPropertyValue -path $VeeamRegPath -Name SqlDatabaseName }
#query string
$query = "SELECT [name],[type] FROM [dbo].[BackupProxies] where type = 6 and name NOT LIKE 'Backup Proxy' or type = 0 AND name NOT LIKE 'VMware Backup Proxy'"
#return results of query on sql server/database
$results = Invoke-Sqlcmd -ServerInstance "$SQLServerName" -Database "$SQLDatabaseName" -Query "$Query"
#if something was returned, write to log file.
if ($results) {
$outString = "VBR server: $VBR. Proxies Below.."
Write-Host "Writing Proxies to text file for $VBR..." -ForegroundColor Green
add-content -Value $results.name -Path $filePathList
Add-Content -Value $outString -Path $fileName
add-content -Value $results.name -Path $fileName
add-content -Value $OFS -Path $fileName
} else {
#if nothing was return, this probably means there is no standalone dedicated proxies.
$outstring = "$VBR Has no standalone proxies."
Write-Host $outString -ForegroundColor Magenta
Add-Content -Value $outString -Path $fileName
Add-Content -Value $OFS -Path $fileName
}
}
#remove all open ps sessions
Get-PSSession | Remove-PSSession
TBH I'm not sure why they return a CHost object here, but I can think of some reasons I might want that in a script to avoid having to do another Get-VBRServer lookup and just have the CHost right there, as the Get-VBRServer lookup can be expensive in larger environments.
Can you provide the entire script that you used? I had to go about it in another way to get it to work like i wanted it to.