PowerShell script exchange
Post Reply
aSmithZimcom
Service Provider
Posts: 9
Liked: never
Joined: Apr 15, 2020 4:32 pm
Full Name: Aaron Smith
Contact:

CloudConnect Tenant Report Automation

Post by aSmithZimcom »

We are a CloudConnect Service Provider. We like the report that is generated CloudConnect > Tenants > Reports

We have resellers setup through VSPC and so they have multiple tenants. We would love to be able to generate a report through PowerShell to export that report. Is that possible? Can I poll VSPC and get all the tenants that are associated with a reseller? Any help would be great.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: CloudConnect Tenant Report Automation

Post by oleg.feoktistov »

Hi Aaron,

Please correct me if I'm wrong, but I suppose that you are talking about the report generated in VBR, not VSPC.
If that's the case, we will be working with VBR Powershell here.
Here is the closest equivalent of that report I could come up with in Powershell:

Code: Select all

$tenants = Get-VBRCloudTenant

Write-Host "Backup:"
foreach ($tenant in $tenants) {
  $cloudrepository = $tenant.Resources.RepositoryFriendlyName
  $repository = $tenant.Resources.Repository.Name
  $totalQuota = $tenant.Resources.RepositoryQuota
  $usedSpace = $tenant.Resources.UsedSpace
  $freeSpace = $totalQuota - $usedSpace
  $lastActive = $tenant.LastActive
  if ($tenant.LeaseExpirationEnabled -eq $true) {
    $expirationDate = $tenant.LeaseExpirationDate
  }
  else {
    $expirationDate = 'never'
  }
  $tenant | select Name, VMCount, @{n='RepositoryName';e={$cloudrepository}}, `
  @{n='Repository';e={$repository}}, @{n='TotalQuota';e={$totalQuota}}, `
  @{n='UsedSpace';e={$usedSpace}}, @{n='FreeSpace';e={$freeSpace}}, `
  @{n='LastActive';e={$lastActive}}, @{n='ExpirationDate';e={$expirationDate}} 
}

Write-Host "Replication:"

foreach ($tenant in $tenants) {
  if ($tenant.LeaseExpirationEnabled -eq $true) {
    $expirationDate = $tenant.LeaseExpirationDate
  }
  else {
    $expirationDate = 'never'
  }
  $lastActive = $tenant.LastActive
  if ($tenant.ReplicationResources) {
  $usedMemory = $tenant.ReplicationResources.HardwarePlanOptions.UsedMemory
  $usedCPU = $tenant.ReplicationResources.HardwarePlanOptions.UsedCPU
  $usedStorage = $tenant.ReplicationResources.HardwarePlanOptions.UsedDatastore
  $hardwarePlan = (Get-VBRCloudHardwarePlan -Id $tenant.ReplicationResources.HardwarePlanOptions.HardwarePlanId).Name
  }
  elseif ($tenant.vCDReplicationResource) {
    $usedMemory = $tenant.vCDReplicationResource.OrganizationVDCOptions.UsedMemory
    $usedCPU = $tenant.vCDReplicationResource.OrganizationVDCOptions.UsedCPU
    $usedStorage = ''
    $hardwarePlan = $tenant.vCDReplicationResource.OrganizationVDCOptions.OrganizationVDCName
  }
  $tenant | select Name, ReplicaCount, @{n='HardwarePlan';e={$hardwarePlan}}, `
  @{n='UsedMemory';e={$usedMemory}}, @{n='UsedCPU';e={$usedCPU}}, `
  @{n='UsedStorage';e={$usedStorage}}, @{n='LastActive';e={$lastActive}}, @{n='ExpirationDate';e={$expirationDate}}
}
Few notes:
1. All numbers related to space quota for backup resources are in megabytes.
2. Used memory and storage values for replication resources are also in megabytes.
3. I found no relevant property for UsedStorage in VCD tenants, so I set it to empty.

Hope it helps,
Oleg
aSmithZimcom
Service Provider
Posts: 9
Liked: never
Joined: Apr 15, 2020 4:32 pm
Full Name: Aaron Smith
Contact:

Re: CloudConnect Tenant Report Automation

Post by aSmithZimcom »

Thanks for the response. That is very helpful. Yes the main goal is through the VBR...the part I am missing and would prefer not to do manually is the collection of what users are under a reseller in VSPC. I know it responds to API calls and I am wondering if there is some way to get that info and then parse it to the script you had.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: CloudConnect Tenant Report Automation

Post by oleg.feoktistov »

I'm not a profi in VSPC, but here should be the REST API call for that. You can use Powershell as a client for your rest requests, format and integrate responses how you want. Native Invoke-RestMethod cmdlet can be a starting point for you. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests