PowerShell script exchange
Post Reply
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

GFS Media pool size and capacity

Post by matteu » 1 person likes this post

Hello,

I would like to audit all the media pool capacity but it's not working for GFS.

This is my script :

Code: Select all

function Get-VeeamTapeMediaPool
{
    Write-host "Veeam Tape Media Pools"
    $VeeamTapeMediaPool = Get-VBRTapeMediaPool
    foreach ($element in $VeeamTapeMediaPool)
    {
        [pscustomobject]@{
            Name = $element.Name
            'Capacity(TB)' = $element.capacity / 1TB -as [int]
            'FreeSpace(TB)' =  $element.FreeSpace / 1TB -as [int]
            MediaSetName = $element.MediaSetName
            RetentionType = $element.RetentionPolicy.type
            RetentionValue = [string] $element.RetentionPolicy.value + " " + $element.RetentionPolicy.period
            Worm = $element.Worm
            LibraryName = (Get-VBRTapeLibrary | Where-Object {$_.id -eq $element.libraryid}).name  
        }
    }
    Write-host "-------------------"
}
It's working perfectly for standard media pool but for GFS there is not property called capacity or freespace and I don't have any result.
I don't find with Get-member something to get it.

Thanks for your help
jcolonfzenpr
Veeam Vanguard
Posts: 44
Liked: 31 times
Joined: Dec 30, 2021 1:16 am
Full Name: Jonathan Colon
Location: Puerto Rico
Contact:

Re: GFS Media pool size and capacity

Post by jcolonfzenpr »

Hello,

Curiously enough, I was doing the same research.

Code: Select all

function Get-VeeamTapeMediaPool
{
    Write-Output "Veeam Tape Media Pools"
    $VeeamTapeMediaPool = Get-VBRTapeMediaPool
    foreach ($element in $VeeamTapeMediaPool)
    {
        if ( $element.Type -ne "Gfs") {
            [pscustomobject]@{
                Name = $element.Name
                'Capacity (TB)' = ([Math]::Round($element.capacity / 1TB, 1))
                'FreeSpace (TB)' =  ([Math]::Round($element.FreeSpace / 1TB, 1))
                'MediaSet Name' = $element.MediaSetName
                'Retention Type' = $element.RetentionPolicy.type
                'Retention Value' = [string] $element.RetentionPolicy.value + " " + $element.RetentionPolicy.period
                'Worm' = $element.Worm
                'Library Name' = (Get-VBRTapeLibrary | Where-Object {$_.id -eq $element.libraryid}).name  
            }
        } elseif ( $element.Type -eq "Gfs") {
            #Get the mediapool mediums and sum them!
            $Capacity = ((Get-VBRTapeMedium -MediaPool $element.Name).Capacity | Measure-Object -Sum).Sum
            $FreeSpace = ((Get-VBRTapeMedium -MediaPool $element.Name).Free | Measure-Object -Sum).Sum
            [pscustomobject]@{
                'Name' = $element.Name
                'Capacity (TB)' = ([Math]::Round($Capacity / 1TB, 1))
                'FreeSpace (TB)' =  ([Math]::Round($FreeSpace / 1TB, 1))
                'Daily Media Set'  = $element.DailyMediaSetOptions.MediaSetPolicy.Name
                'Weekly Media Set'  = $element.WeeklyMediaSetOptions.MediaSetPolicy.Name
                'Monthly Media Set'  = $element.MonthlyMediaSetOptions.MediaSetPolicy.Name
                'Quarterly Media Set'  = $element.QuarterlyMediaSetOptions.MediaSetPolicy.Name
                'Yearly Media Set'  = $element.YearlyMediaSetOptions.MediaSetPolicy.Name
                'Worm' = $element.Worm
                'Library Name' = (Get-VBRTapeLibrary | Where-Object {$_.id -eq $element.libraryid}).name
            }
        }
    }
    Write-Output "-------------------"
}
Regards, Jon
Jonathan Colon
https://techmyth.blog/
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: GFS Media pool size and capacity

Post by oleg.feoktistov »

Hi matteu,

For some reason these properties are not implemented for GFS media pools (standard and gfs media pools are of distinct classes).
Nonetheless, here is the workaround with .NET method:

Code: Select all

[Veeam.Tape.Core.CTapeMediaPool]::GetUserGfsMediaPools() | select Name, Capacity, Free
Cheers,
Oleg
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: GFS Media pool size and capacity

Post by matteu »

Hello,

Thank you for your answer.
I'm sorry but I don't know how to work with .NET .
I would like to use it with custom object but I don't know how to integrate it. This is my "bad" try

Code: Select all

$VeeamTapeMediaPool = Get-VBRTapeMediaPool
foreach ($element in $VeeamTapeMediaPool)
{
    if ( $element.Type -eq "Gfs") {
        $element.[Veeam.Tape.Core.CTapeMediaPool]::GetUserGfsMediaPools().CapacityString
    }
}
Where can I find the help for GetFreeMediaPool method ? I try to put $element between parenteses but it's not working too.
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: GFS Media pool size and capacity

Post by matteu »

OK finally, I create 2 differents functions because they have not the same properties.

This is my result for standard media pool:

Code: Select all

<#
Location : Inventory -> Tape Infrastructure -> Media Pools

Name : Media Pool name
Description : Media pool description
LibraryName : Library name
Capacity(TB) : Media Pool capacity
FreeSpace(TB) :  Media Pool free space
RetentionType : Media Pool retention type
RetentionValue : Media Pool retention value
ParallelProcessing : Parallel processing state
    N/A : Not enabled
    1/2/3/... Parallel processing number
TaskParalleling : Parallel processing of backup chains within a single tape job state
    True : Parallel processing of backup chains within a single tape job is enabled
    False : Parallel processing of backup chains within a single tape job is not enabled
Worm : status worm on media pool
    true : worm is enabled
    false : worm is disabled
Encryption : Encryption state
    True : Encryption is enabled
    False : Encryption is not enabled
#>
function Get-VeeamStandardTapeMediaPool
{
    Write-Output "Veeam Tape Media Pools"
    $VeeamTapeMediaPool = Get-VBRTapeMediaPool
    foreach ($element in $VeeamTapeMediaPool)
    {
        if ( $element.Type -ne "Gfs") {
            if($element.MultiStreamingOptions.Enabled)
            {
                $ParallelProcessing=$element.MultiStreamingOptions.NumberOfStreams
                if($element.MultiStreamingOptions.SplitJobFilesBetweenDrives)
                {
                    $TaskParalleling = $true
                }
                else
                {
                    $TaskParalleling = $false
                }
            }
            else
            {
                $ParallelProcessing = $false
                $TaskParalleling = $false
            }

            [pscustomobject]@{
                Name = $element.Name
                Description = $element.Description
                LibraryName = (Get-VBRTapeLibrary | Where-Object {$_.id -eq $element.libraryid}).name 
                'Capacity (TB)' = $element.capacity / 1TB -as [int]
                'FreeSpace (TB)' =  $element.FreeSpace / 1TB -as [int]
                MediaSetName = $element.MediaSetName
                RetentionType = $element.RetentionPolicy.type
                RetentionValue = [string] $element.RetentionPolicy.value + " " + $element.RetentionPolicy.period
                ParallelProcessing = $ParallelProcessing
                TaskParalleling = $TaskParalleling
                WORM = $element.Worm
                Encryption = $element.EncryptionOptions.Enabled                
            }
        }
    }
    Write-Output "-------------------"
}
and this one for gfs media pool

Code: Select all

<#
Location : Inventory -> Tape Infrastructure -> Media Pools

Name : Media Pool name
Description : Media pool description
LibraryName : Library name
'Capacity(TB)' : Media Pool capacity
'FreeSpace(TB)' :  Media Pool free space
DailyMediaSet : Daily media set name
DailyRetention : Daily media set retention
WeeklyMediaSet : Weekly media set name
WeeklyRetention : Weekly media set name
MonthlyMediaSet : Monthly media set name
MonthlyRetention : Monthly media set name
QuarterlyMediaSet : Quarterly media set name
QuarterlyRetention : Quarterly media set name
YearlyMediaSet : Yearly media set name
YearlyRetention : Yearly media set name
ParallelProcessing : Parallel processing state
    N/A : Not enabled
    1/2/3/... Parallel processing number
TaskParalleling : Parallel processing of backup chains within a single tape job state
    True : Parallel processing of backup chains within a single tape job is enabled
    False : Parallel processing of backup chains within a single tape job is not enabled
Worm : status worm on media pool
    true : worm is enabled
    false : worm is disabled
Encryption : Encryption state
    True : Encryption is enabled
    False : Encryption is not enabled
#>
function Get-VeeamGFSTapeMediaPool
{
    Write-Output "Veeam GFS Tape Media Pools"
    $VeeamGFSTapeMediaPool = [Veeam.Tape.Core.CTapeMediaPool]::GetUserGfsMediaPools()
    foreach ($element in $VeeamGFSTapeMediaPool)
    {
        $DailyRetention = if ($element.Options.GfsDailyOptions.Enabled)
                          {
                               [string] $element.Options.GfsDailyOptions.RetentionPeriod.value + " " + $element.Options.GfsDailyOptions.RetentionPeriod.Type                            
                          }
                          else 
                          {
                                "<N/A>"
                          }
        $WeeklyRetention = if ($element.Options.GfsWeeklyOptions.Enabled)
                          {
                               [string] $element.Options.GfsWeeklyOptions.RetentionPeriod.value + " " + $element.Options.GfsWeeklyOptions.RetentionPeriod.Type                            
                          }
                          else 
                          {
                                "<N/A>"
                          }        
        $MonthlyRetention = if ($element.Options.GfsMonthlyOptions.Enabled)
                          {
                               [string] $element.Options.GfsMonthlyOptions.RetentionPeriod.value + " " + $element.Options.GfsMonthlyOptions.RetentionPeriod.Type                            
                          }
                          else 
                          {
                                "<N/A>"
                          }        
        $QuarterlyRetention = if ($element.Options.GfsQuarterlyOptions.Enabled)
                          {
                               [string] $element.Options.GfsQuarterlyOptions.RetentionPeriod.value + " " + $element.Options.GfsQuarterlyOptions.RetentionPeriod.Type                            
                          }
                          else 
                          {
                                "<N/A>"
                          }        
        $YearlyRetention = if ($element.Options.GfsYearlyOptions.Enabled)
                          {
                               [string] $element.Options.GfsYearlyOptions.RetentionPeriod.value + " " + $element.Options.GfsYearlyOptions.RetentionPeriod.Type                            
                          }
                          else 
                          {
                                "<N/A>"
                          }
        if ($element.Options.ParallelProcessingOptions.Enabled)
        {
            $ParallelProcessing=$element.Options.ParallelProcessingOptions.DrivesCountToUse
            if ($element.Options.ParallelProcessingOptions.TaskParalleling)
            {
                $TaskParalleling = $true
            }
            else
            {
                $TaskParalleling = $false
            }
        }
        else
        {
            $ParallelProcessing = $false
            $TaskParalleling = $false
        }                            

        [pscustomobject]@{
            Name = $element.Name
            Description = $element.Description
            LibraryName = $element.HighestPriorityLibrary.Name 
            'Capacity (TB)' = $element.capacityString
            'FreeSpace (TB)' =  $element.FreeString
            DailyMediaSet  = $element.Options.GfsDailyOptions.MediaSetName
            DailyRetention = $DailyRetention
            WeeklyMediaSet  = $element.Options.GfsWeeklyOptions.MediaSetName
            WeeklyRetention = $WeeklyRetention
            MonthlyMediaSet  = $element.Options.GfsMonthlyOptions.MediaSetName
            MonthlyRetention = $MonthlyRetention
            QuarterlyMediaSet  = $element.Options.GfsQuarterlyOptions.MediaSetName
            QuarterlyRetention = $QuarterlyRetention
            YearlyMediaSet  = $element.Options.GfsYearlyOptions.MediaSetName
            YearlyRetention = $YearlyRetention
            ParallelProcessing = $ParallelProcessing 
            TaskParalleling = $TaskParalleling
         [b]   WORM = if ($element.TapeType -eq "WORM tape") {$true} else {$false}  [/b]
            Encryption = $element.IsEncryptionEnabled      
        }
    }
    Write-Output "-------------------"
}
I'm not sure if I choose the good method to identify worm type or not.
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: GFS Media pool size and capacity

Post by david.domask »

Hey matteu,

Sure, it's fine the way you have it :)

But in fact you even wrote more than you need to, that is, you don't need to define an else there for $false; it's implied if the condition isn't true.

Code: Select all

PS /Users/vvvvvv> $variable = "some string"
PS /Users/vvvvvv> ($variable -eq "some string")  
True
PS /Users/vvvvvv> ($variable -eq "some other string")  
False
Not like what you did is wrong, but can save some typing, and I think it makes it a bit more legible. Of course if you need another action for if $false, then define it in an else statement.
David Domask | Product Management: Principal Analyst
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: GFS Media pool size and capacity

Post by matteu »

Hello,

Thanks for your answer.
You re absolutelly true and this will help me a lot for ALL the stuff i already did :) and the future one :)
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests