PowerShell script exchange
Post Reply
rweis
Veeam Software
Posts: 461
Liked: 71 times
Joined: Jun 13, 2011 7:46 pm
Full Name: Randy Weis
Location: Raleigh, NC, USA
Contact:

v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by rweis »

Customer just upgraded to v11 this week and when he runs this script it doesn’t provide all the info it did before. In the DisksSpecific field rather than giving the disk id (ex: 0:0, 0:1, 0:2, etc.) it just has an entry for each disk that say “Veeam.Backup.Model.CDiskKeyInfo”. So if a server has 4 disks being backed up that same line will be in the field 4 times. It seems that the way v11 describes this information has changed, or the label has changed, or something. Can you provide guidance?
Here is the script:

Code: Select all

#Requires -Version 4
#Requires -RunAsAdministrator
<#
.Synopsis
   Simple Veeam report to expand on information from 'Veeam Backup Billing' report in VeeamOne
.Notes
    Version: 0.1
    Author: Joe Houghes
    Modified Date: 2-27-2019
.EXAMPLE
   Get-VMandDiskFilterDetails | Format-Table
.EXAMPLE
   Get-VMandDiskFilterDetails | Export-Csv VM_DiskFilterDetails.csv -NoTypeInformation
#>


#Load the Veeam PSSnapin
<#
if (!(Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue)) {
  Add-PsSnapin -Name VeeamPSSnapIn
}
#>

function Get-VMandDiskFilterDetails{
  $reportJobOutput = @()

  $reportJobs = Get-VBRJob | Where-Object {$PSItem.JobType -eq 'Backup' -OR $PSItem.JobType -eq 'BackupSync' -AND $PSItem.BackupPlatform.Platform -eq 'EVmware'}
  $repositories = Get-VBRBackupRepository | Select-Object Name,Id

  foreach ($reportJob in $reportJobs) {

    $currentBackup = Get-VBRBackup -Name $reportJob.Name
    $currentRepo = $repositories | Where-Object -Property Id -eq -Value $currentBackup.RepositoryId
    $currentJobVMs = $reportJob.GetViOijs() | Select-Object Name, @{n='JobName';e={$reportjob.Name}}, @{n='Mode'; e={$PSItem.DiskFilterInfo.Mode}}, @{n='Disks'; e={$PSItem.DiskFilterInfo.Disks}}

      foreach ($currentVM in $currentJobVMs) {
        $reportJobOutputObject = New-Object -TypeName PSCustomObject -Property @{
          'BackupJob' = $reportJob.Name
          'VMName' =  $currentVM.Name
          'Location' = $currentRepo.Name
          'DiskMode' = $currentVM.Mode
          'DisksSpecific' = $currentVM.Disks
        }

        $reportJobOutput += $reportJobOutputObject
      }
    }
    
    Write-Output $reportJobOutput | Select-Object 'BackupJob','VMName','Location','DiskMode','DisksSpecific'
    
}  
Randy Weis
Enterprise SE, NA Strategic Accounts
Gostev
Chief Product Officer
Posts: 31561
Liked: 6724 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by Gostev » 1 person likes this post

It's the perfect demonstration why you should never attach to internal classes in PowerShell scripts... these structures change every time, causing constant headache for everyone.

@oleg.feoktistov can you please find out what has changed here?
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by oleg.feoktistov » 2 people like this post

Anton has a point. Will check once the lab is upgraded and update the thread. Thanks!
k00laid
Veeam Vanguard
Posts: 222
Liked: 51 times
Joined: Jan 13, 2011 5:42 pm
Full Name: Jim Jones
Location: Hurricane, WV
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by k00laid » 1 person likes this post

@Gostev, in his defense we have to use internal classes for many things reporting wise as they aren't exposed via properties. I 100% agree that it is a constant headache for everyone, ran into this just trying to pull disk space information on repositories last week. Can we consider removing powershell and API from the product release cycle to allow for faster development so that more and more of these classes can be promoted to properties?
If I were to dare to dream I'd ask for powershell to only be tied to major version either, this is a massive headache for those of us with lots of VBR servers that may have minor version differences between all of them.
Jim Jones, Sr. Product Infrastructure Architect @iland / @1111systems, Veeam Vanguard
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by soncscy » 1 person likes this post

Side note, this script is really ugly for me :/

I think the desired data is simply under DiskFilter now:

Code: Select all

PS C:\Users\Administrator> $job = Get-vbRJob -Name 'per-backup-chain'
PS C:\Users\Administrator> $job.GetViOijs()[1].DiskFilter.disks

Key                   DisplayName
---                   -----------
SCSI 0:0 (Raw: 2000)  SCSI (0:0)
SCSI 0:4 (Raw: 2004)  SCSI (0:4)
SCSI 0:8 (Raw: 2008)  SCSI (0:8)
SCSI 0:9 (Raw: 2009)  SCSI (0:9)
SCSI 0:11 (Raw: 2011) SCSI (0:11)
SCSI 0:12 (Raw: 2012) SCSI (0:12)
This returns all included disks under the Filter. You'd have to go into the OIB.AuxData.DisksInfos values to get the disks actually backed up (and honestly doesn't this maybe make more sense to pull the data from there since it's actually backed up and you get some real stats on it?)

Is this what you're looking for though? It's really not so clear what you're seeking from the description or what the desired output should contain as I don't quite get how this helps with billing if you just get scsi ids.

Looks like this is for a billing report, but seems barbaric...
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by jhoughes »

Yes, as stated in the synopsis, it is built to expand on the details within the VeeamOne Backup Billing report, and to fit a specific need to find disk filters without a "stare & compare" method of digging into submenus.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by oleg.feoktistov » 1 person likes this post

Okay, I tested it in few different labs with VBR v11 GA and the output is the same: DisksSpecific property is just null. No class type reflected.
It makes me wonder why is it different in the customer's production site.
Anyways, if it comes to retrieving which disks are backed up, wouldn't it be better to obtain information about the disks already backed up?
@rweis, please, let me know if Get-VBRViVirtualDevice cmdlet works for the customer. It retrieves a list of virtual disks for each restore point created.
Thanks!
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by jhoughes »

@oleg.feoktistov the intention of this was for them to report on the current status of any disk filters within jobs.

I'll try to dig into a workaround for this, I sent Randy to the forums for assistance as I was busy and didn't want this to be only email support for a 2 year old script from an older version.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by oleg.feoktistov »

@k00laid,

Usually we share scripts with internal classes as workarounds because we understand that not all is covered with powershell cmdlets and are ready to help. But those are provided on forum's best effort and have huge "Not supported" disclaimer and we do our best to mention that every time.
I'm not sure what you mean by 'classes can be promoted to properties'. When we want to wrap internal class with a PS-compliant, we create a new object, which is meant to have fixed properties and put it to a separate namespace. So, technically, 'promoting' means creating a new class for the same entity, design new cmdlets for those and deprecate older objects/cmdlets.

Best regards,
Oleg
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by oleg.feoktistov »

@jhoughes, thanks, understood! I'll also try to dig it in parallel. Thanks!
k00laid
Veeam Vanguard
Posts: 222
Liked: 51 times
Joined: Jan 13, 2011 5:42 pm
Full Name: Jim Jones
Location: Hurricane, WV
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by k00laid » 3 people like this post

@oleg.feoktistov,

I mean, for example, in v11 to get free space on a a bunch of repos you needed to do

Code: Select all

$Repos = Get-VBRBackupRepository
$RepoDetails = foreach ($repo in $Repos) {
    [PSCustomObject]@{
        'Name'      = $Repo.Name
        'ID'        = $Repo.ID
        'Size'      = $Repo.GetContainer().CachedTotalSpace.InBytes / 1GB
        'FreeSpace' = $Repo.GetContainer().CachedFreeSpace.InBytes / 1GB
    }
} 
$RepoDetails
If things as normal in typical use such as free space and total space were properties of the repo itself it would be far more consumable and discoverable.

Code: Select all

Get-VBRRepository | select name,id,CachedTotalSpace,CachedFreeSpace
You could pull all the properties for a given repo and find common information. This is just one example of very common information and/or settings that is buried in the GetContainer, Info and Config classes that are poorly documented and painful to discover. Using this in contrast to say VMware's PowerCLI is like night and day.
Jim Jones, Sr. Product Infrastructure Architect @iland / @1111systems, Veeam Vanguard
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by oleg.feoktistov »

Jim,

I feel your pain and, to be honest, that particular case was a surprise for me either. But it's still internal class (CBackupReposirtory) and such changes are expected. Especially, in those older classes, which were tied to PS cmdlets from the beginning of times. To fix that it would require either of 2 things:
  • Creating a separate object for, say, repositories with most valued properties together with a new cmdlet and deprecate older cmdlet.
  • Creating a new object and tie it to existing cmdlet, which would break compatibility, but easier to develop.
I believe, sticking to the first approach is more convenient and flexible, yet requires more time to implement.
Though I hope that, at last, we will be able to transform them all and the headache ceases.

Best regards,
Oleg
rweis
Veeam Software
Posts: 461
Liked: 71 times
Joined: Jun 13, 2011 7:46 pm
Full Name: Randy Weis
Location: Raleigh, NC, USA
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by rweis »

Checking in with Customer and getting out of the middle! Thanks for the responses, all.
Randy Weis
Enterprise SE, NA Strategic Accounts
bschmeltz
Lurker
Posts: 2
Liked: 1 time
Joined: Mar 05, 2021 4:32 pm
Full Name: Brian Schmeltz
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by bschmeltz » 1 person likes this post

Running the "Get-VBRViVirtualDevice" doesn't give us what we are looking for. The script we had would go through all of our backup jobs and list out the information listed below. This gave us a quick way to produce reports to our application teams so they can identify what servers they have being backed up, which disks, and how often. After upgrading to v11 everything still works except the DiskSpecific field, that one just shows "Veeam.Backup.Model.CDiskKeyInfo" for each disk instead of including the SCSI ID. In the past this is a script we have actually had scheduled so that it can run regularly to provide updated reports. We are looking to be able to do that still but if that isn't an option we will have to come up with another solution.

Script Output Example:
Backup Job VMName Location DiskMode DiskSpecific
Nightly Backup Server A Repository A Selected Disks SCSI 0:0, 0:2
Weekly Backup Server B Repository B Selected Disks SCSI 0:0, 0:2
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by jhoughes » 5 people like this post

The script has been updated and tweaked to have better formatting & slightly improved performance.

Both the v11 & older versions are uploaded to VeeamHub now.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
bschmeltz
Lurker
Posts: 2
Liked: 1 time
Joined: Mar 05, 2021 4:32 pm
Full Name: Brian Schmeltz
Contact:

Re: v11 change? ‘DisksSpecific’ = $currentVM.Disks returns a non-specific answer

Post by bschmeltz »

That script works exactly as we need it. Thank you very much.
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests