PowerShell script exchange
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: My Veeam Report v9.5.1

Post by Natalia Lupacheva »

Hi Kalaimani,

Seems you didn't comment out the line with Add-PSSnapin as it's recommended here (you can also find more details here).

Could you comment this line and try again?

Thanks!
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Dear All,

I'm Running script Veeam server itself, if I'm able to Add-PSSnapin veeampssnapin then it'll work everything
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov »

Hi Kalaimani,

If you use the script on machine with VBR console v10 installed, it makes sense. If with v11, you wouldn't be able to add snap-in anymore as we migrated our powershell library to module.

Thanks,
Oleg
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Hi, someone helps me with my request,

1st errors are not able to add the Add-PSSnapin veeampssnapin
2nd not able to get the repository information
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov »

Please, re-read previous messages from my colleagues and me. The steps to resolve your issues are already there.

1. If you updated to VBR v11, you won't be able to import VeeamPSSnapin as there isn't one. It's a module there now, which is imported automatically upon VBR console installation.

2. Check out the link to the post Joe shared.

Thanks!
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

someone deleting my post
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Dear Oleg,

In this case how we are getting get the repository information,
it's working without any issue before upgrading to Veeam 11.

I'm badly looking for a fix for this issue
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: My Veeam Report v9.5.1

Post by Natalia Lupacheva »

@kalaimani53,
You have faced the issue
Add-PSSnapin : The Windows PowerShell snap-in 'veeampssnapin' is not installed on this computer.
At line:1 char:1
+ Add-PSSnapin veeampssnapin
after upgrade to V11 because you cannot add it on v11.
That means you need to look up your script and comment (put # symbol at the beginning of the line) or remove the line with text "Add-PSSnapin" from your script.
When you do it, try to run the script again.

Thanks!
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

I'm able to run the script veeampssnapin but not able to get the repertory information, that is the actual issue
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: My Veeam Report v9.5.1

Post by Natalia Lupacheva »

@kalaimani53, could you please more specific what exactly did not work with the solution provided by Joe? Did you check it?
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Is there any way to attach the txt file,
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: My Veeam Report v9.5.1

Post by Natalia Lupacheva »

No. But you can describe the exact problem you've faced using the suggested script.

I see you've asked for the way to get repository info and Joe suggested you to check the script from this thread.
1. Have you checked this thread?
2. Have you tried to het the script from it?
3. Could you describe the exact problems you get when you try to get repository info?

Thanks!
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

1. Have you checked this thread?
yes,
2. Have you tried to het the script from it?
yes
3. Could you describe the exact problems you get when you try to get repository info?

I'm using the below script, if you run it you will get the exact error

Code: Select all

Connect-VBRServer -Server 
$server = "" #SMTP Server information 
$date= Get-Date -Format ddMMyyyy
$time =Get-Date
$users = "" # Users to be notified 
$fromemail = ""
# Repository Free Space Remaining %
$repoCritical = 10


$repoWarn = 20
# Show Repository Info
$showRepo = $true
# Get all Repositories
$repoList = Get-VBRBackupRepository
# Get Repository Info


Function Get-VBRRepoInfo {
  [CmdletBinding()]
  param (
    [Parameter(Position=0, ValueFromPipeline=$true)]
    [PSObject[]]$Repository
  )
  Begin {
    $outputAry = @()
    Function Build-Object {param($name, $repohost, $path, $free, $total, $maxtasks, $rtype)
      $repoObj = New-Object -TypeName PSObject -Property @{
        Target = $name
        RepoHost = $repohost
        Storepath = $path
        StorageFree = [Math]::Round([Decimal]$free/1GB,2)
        StorageTotal = [Math]::Round([Decimal]$total/1GB,2)
        FreePercentage = [Math]::Round(($free/$total)*100)
        MaxTasks = $maxtasks
        rType = $rtype
      }
      Return $repoObj
    }
  }
  Process {
    Foreach ($r in $Repository) {
      # Refresh Repository Size Info
      [Veeam.Backup.Core.CBackupRepositoryEx]::SyncSpaceInfoToDb($r, $true)
      $rType = switch ($r.Type) {
        "WinLocal" {"Windows Local"}
        "LinuxLocal" {"Linux Local"}
        "CifsShare" {"CIFS Share"}
        "DataDomain" {"Data Domain"}
        "ExaGrid" {"ExaGrid"}
        "HPStoreOnce" {"HP StoreOnce"}
        default {"Unknown"}   
      }
      $outputObj = Build-Object $r.Name $($r.GetHost()).Name.ToLower() $r.Path $r.info.CachedFreeSpace $r.Info.CachedTotalSpace $r.Options.MaxTaskCount $rType
    }
    $outputAry += $outputObj
  }
  End {
    $outputAry
  }
}


Function Get-VBRSORepoInfo {
  [CmdletBinding()]
  param (
    [Parameter(Position=0, ValueFromPipeline=$true)]
    [PSObject[]]$Repository
  )
  Begin {
    $outputAry = @()
    Function Build-Object {param($name, $rname, $repohost, $path, $free, $total, $maxtasks, $rtype)
      $repoObj = New-Object -TypeName PSObject -Property @{
        SoTarget = $name
        Target = $rname
        RepoHost = $repohost
        Storepath = $path
        StorageFree = [Math]::Round([Decimal]$free/1GB,2)
        StorageTotal = [Math]::Round([Decimal]$total/1GB,2)
        FreePercentage = [Math]::Round(($free/$total)*100)
        MaxTasks = $maxtasks
        rType = $rtype
      }
      Return $repoObj
    }
  }
  Process {
    Foreach ($rs in $Repository) {
      ForEach ($rp in $rs.Extent) {
        $r = $rp.Repository 
        # Refresh Repository Size Info
        [Veeam.Backup.Core.CBackupRepositoryEx]::SyncSpaceInfoToDb($r, $true)           
        $rType = switch ($r.Type) {
          "WinLocal" {"Windows Local"}
          "LinuxLocal" {"Linux Local"}
          "CifsShare" {"CIFS Share"}
          "DataDomain" {"Data Domain"}
          "ExaGrid" {"ExaGrid"}
          "HPStoreOnce" {"HP StoreOnce"}
          default {"Unknown"}     
        }
        $outputObj = Build-Object $rs.Name $r.Name $($r.GetHost()).Name.ToLower() $r.Path $r.info.CachedFreeSpace $r.Info.CachedTotalSpace $r.Options.MaxTaskCount $rType
        $outputAry += $outputObj
      }
    } 
  }
  End {
    $outputAry
  }
}


# Get Repository Info
$bodyRepo = $null
If ($showRepo) {
  If ($repoList -ne $null) {
    $arrRepo = $repoList | Get-VBRRepoInfo | Select @{Name="Repository Name"; Expression = {$_.Target}},
      @{Name="Type"; Expression = {$_.rType}}, @{Name="Max Tasks"; Expression = {$_.MaxTasks}},
      @{Name="Host"; Expression = {$_.RepoHost}}, @{Name="Path"; Expression = {$_.Storepath}},
      @{Name="Free (GB)"; Expression = {$_.StorageFree}}, @{Name="Total (GB)"; Expression = {$_.StorageTotal}},
      @{Name="Free (%)"; Expression = {$_.FreePercentage}},
      @{Name="Status"; Expression = {
        If ($_.FreePercentage -lt $repoCritical) {"Critical"}
        ElseIf ($_.StorageTotal -eq 0)  {"Warning"} 
        ElseIf ($_.FreePercentage -lt $repoWarn) {"Warning"}
        ElseIf ($_.FreePercentage -eq "Unknown") {"Unknown"}
        Else {"OK"}}
      }
    $bodyRepo = $arrRepo | Sort "Repository Name" | ConvertTo-HTML -Fragment       
    If ($arrRepo.status -match "Critical") {
      $repoHead = $subHead01err
    } ElseIf ($arrRepo.status -match "Warning|Unknown") {
      $repoHead = $subHead01war
    } ElseIf ($arrRepo.status -match "OK") {
      $repoHead = $subHead01suc
    } Else {
      $repoHead = $subHead01
    }    
    $bodyRepo = $repoHead + "Repository Details" + $subHead02 + $bodyRepo
  }
}

# Get Scale Out Repository Info
$bodySORepo = $null
If ($showRepo) {
  If ($repoListSo -ne $null) {
    $arrSORepo = $repoListSo | Get-VBRSORepoInfo | Select @{Name="Scale Out Repository Name"; Expression = {$_.SOTarget}},
      @{Name="Member Repository Name"; Expression = {$_.Target}}, @{Name="Type"; Expression = {$_.rType}},
      @{Name="Max Tasks"; Expression = {$_.MaxTasks}}, @{Name="Host"; Expression = {$_.RepoHost}},
      @{Name="Path"; Expression = {$_.Storepath}}, @{Name="Free (GB)"; Expression = {$_.StorageFree}},
      @{Name="Total (GB)"; Expression = {$_.StorageTotal}}, @{Name="Free (%)"; Expression = {$_.FreePercentage}},
      @{Name="Status"; Expression = {
        If ($_.FreePercentage -lt $repoCritical) {"Critical"}
        ElseIf ($_.StorageTotal -eq 0)  {"Warning"}
        ElseIf ($_.FreePercentage -lt $repoWarn) {"Warning"}
        ElseIf ($_.FreePercentage -eq "Unknown") {"Unknown"}
        Else {"OK"}}
      }
    $bodySORepo = $arrSORepo | Sort "Scale Out Repository Name", "Member Repository Name" | ConvertTo-HTML -Fragment
    If ($arrSORepo.status -match "Critical") {
      $sorepoHead = $subHead01err
    } ElseIf ($arrSORepo.status -match "Warning|Unknown") {
      $sorepoHead = $subHead01war
    } ElseIf ($arrSORepo.status -match "OK") {
      $sorepoHead = $subHead01suc
    } Else {
      $sorepoHead = $subHead01
    }
    $bodySORepo = $sorepoHead + "Scale Out Repository Details" + $subHead02 + $bodySORepo
  }
}
   
$HTMLmessage = @" 
 <font face="Microsoft Tai le"> 
 <br /><br />
         <h1 style="background-color:powderblue;text-align: center"> Veeam Repo info</h1>
$bodyRepo
$bodySORepo
    <br /><br />
</font> 
<br> <br> 
<!--mce:0--> 
<body BGCOLOR=""white""> 
<br> <br>  </font> 
</body> 
"@  
 send-mailmessage -from $fromemail -to $users -subject "Veeam Repo info : $time" -BodyAsHTML -body $bodyRepo -priority High -smtpServer $server
Last edited by Natalia Lupacheva on Mar 09, 2021 4:05 pm, edited 2 times in total.
Reason: code formatting
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Dear All, are you able to check my issue
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Dear Joe,

looks like having an issue with Refresh Repository Size Info in the Function, It says all the repository total size is 0 when run whiteout FreePercentage

Code: Select all

# FreePercentage = [Math]::Round(($free/$total)*100)

 # Refresh Repository Size Info
        [Veeam.Backup.Core.CBackupRepositoryEx]::SyncSpaceInfoToDb($r, $true)      

----------------------------------------------------------------------------------------

Connect-VBRServer -Server 
$server = "" #SMTP Server information 
$date= Get-Date -Format ddMMyyyy
$time =Get-Date
$users = "" # Users to be notified 
$fromemail = ""
# Repository Free Space Remaining %
$repoCritical = 10


$repoWarn = 20
# Show Repository Info
$showRepo = $true
# Get all Repositories
$repoList = Get-VBRBackupRepository
# Get Repository Info


Function Get-VBRRepoInfo {
  [CmdletBinding()]
  param (
    [Parameter(Position=0, ValueFromPipeline=$true)]
    [PSObject[]]$Repository
  )
  Begin {
    $outputAry = @()
    Function Build-Object {param($name, $repohost, $path, $free, $total, $maxtasks, $rtype)
      $repoObj = New-Object -TypeName PSObject -Property @{
        Target = $name
        RepoHost = $repohost
        Storepath = $path
        StorageFree = [Math]::Round([Decimal]$free/1GB,2)
        StorageTotal = [Math]::Round([Decimal]$total/1GB,2)
        FreePercentage = [Math]::Round(($free/$total)*100)
        MaxTasks = $maxtasks
        rType = $rtype
      }
      Return $repoObj
    }
  }
  Process {
    Foreach ($r in $Repository) {
      # Refresh Repository Size Info
      [Veeam.Backup.Core.CBackupRepositoryEx]::SyncSpaceInfoToDb($r, $true)
      $rType = switch ($r.Type) {
        "WinLocal" {"Windows Local"}
        "LinuxLocal" {"Linux Local"}
        "CifsShare" {"CIFS Share"}
        "DataDomain" {"Data Domain"}
        "ExaGrid" {"ExaGrid"}
        "HPStoreOnce" {"HP StoreOnce"}
        default {"Unknown"}   
      }
      $outputObj = Build-Object $r.Name $($r.GetHost()).Name.ToLower() $r.Path $r.info.CachedFreeSpace $r.Info.CachedTotalSpace $r.Options.MaxTaskCount $rType
    }
    $outputAry += $outputObj
  }
  End {
    $outputAry
  }
}


Function Get-VBRSORepoInfo {
  [CmdletBinding()]
  param (
    [Parameter(Position=0, ValueFromPipeline=$true)]
    [PSObject[]]$Repository
  )
  Begin {
    $outputAry = @()
    Function Build-Object {param($name, $rname, $repohost, $path, $free, $total, $maxtasks, $rtype)
      $repoObj = New-Object -TypeName PSObject -Property @{
        SoTarget = $name
        Target = $rname
        RepoHost = $repohost
        Storepath = $path
        StorageFree = [Math]::Round([Decimal]$free/1GB,2)
        StorageTotal = [Math]::Round([Decimal]$total/1GB,2)
        FreePercentage = [Math]::Round(($free/$total)*100)
        MaxTasks = $maxtasks
        rType = $rtype
      }
      Return $repoObj
    }
  }
  Process {
    Foreach ($rs in $Repository) {
      ForEach ($rp in $rs.Extent) {
        $r = $rp.Repository 
        # Refresh Repository Size Info
        [Veeam.Backup.Core.CBackupRepositoryEx]::SyncSpaceInfoToDb($r, $true)           
        $rType = switch ($r.Type) {
          "WinLocal" {"Windows Local"}
          "LinuxLocal" {"Linux Local"}
          "CifsShare" {"CIFS Share"}
          "DataDomain" {"Data Domain"}
          "ExaGrid" {"ExaGrid"}
          "HPStoreOnce" {"HP StoreOnce"}
          default {"Unknown"}     
        }
        $outputObj = Build-Object $rs.Name $r.Name $($r.GetHost()).Name.ToLower() $r.Path $r.info.CachedFreeSpace $r.Info.CachedTotalSpace $r.Options.MaxTaskCount $rType
        $outputAry += $outputObj
      }
    } 
  }
  End {
    $outputAry
  }
}


# Get Repository Info
$bodyRepo = $null
If ($showRepo) {
  If ($repoList -ne $null) {
    $arrRepo = $repoList | Get-VBRRepoInfo | Select @{Name="Repository Name"; Expression = {$_.Target}},
      @{Name="Type"; Expression = {$_.rType}}, @{Name="Max Tasks"; Expression = {$_.MaxTasks}},
      @{Name="Host"; Expression = {$_.RepoHost}}, @{Name="Path"; Expression = {$_.Storepath}},
      @{Name="Free (GB)"; Expression = {$_.StorageFree}}, @{Name="Total (GB)"; Expression = {$_.StorageTotal}},
      @{Name="Free (%)"; Expression = {$_.FreePercentage}},
      @{Name="Status"; Expression = {
        If ($_.FreePercentage -lt $repoCritical) {"Critical"}
        ElseIf ($_.StorageTotal -eq 0)  {"Warning"} 
        ElseIf ($_.FreePercentage -lt $repoWarn) {"Warning"}
        ElseIf ($_.FreePercentage -eq "Unknown") {"Unknown"}
        Else {"OK"}}
      }
    $bodyRepo = $arrRepo | Sort "Repository Name" | ConvertTo-HTML -Fragment       
    If ($arrRepo.status -match "Critical") {
      $repoHead = $subHead01err
    } ElseIf ($arrRepo.status -match "Warning|Unknown") {
      $repoHead = $subHead01war
    } ElseIf ($arrRepo.status -match "OK") {
      $repoHead = $subHead01suc
    } Else {
      $repoHead = $subHead01
    }    
    $bodyRepo = $repoHead + "Repository Details" + $subHead02 + $bodyRepo
  }
}

# Get Scale Out Repository Info
$bodySORepo = $null
If ($showRepo) {
  If ($repoListSo -ne $null) {
    $arrSORepo = $repoListSo | Get-VBRSORepoInfo | Select @{Name="Scale Out Repository Name"; Expression = {$_.SOTarget}},
      @{Name="Member Repository Name"; Expression = {$_.Target}}, @{Name="Type"; Expression = {$_.rType}},
      @{Name="Max Tasks"; Expression = {$_.MaxTasks}}, @{Name="Host"; Expression = {$_.RepoHost}},
      @{Name="Path"; Expression = {$_.Storepath}}, @{Name="Free (GB)"; Expression = {$_.StorageFree}},
      @{Name="Total (GB)"; Expression = {$_.StorageTotal}}, @{Name="Free (%)"; Expression = {$_.FreePercentage}},
      @{Name="Status"; Expression = {
        If ($_.FreePercentage -lt $repoCritical) {"Critical"}
        ElseIf ($_.StorageTotal -eq 0)  {"Warning"}
        ElseIf ($_.FreePercentage -lt $repoWarn) {"Warning"}
        ElseIf ($_.FreePercentage -eq "Unknown") {"Unknown"}
        Else {"OK"}}
      }
    $bodySORepo = $arrSORepo | Sort "Scale Out Repository Name", "Member Repository Name" | ConvertTo-HTML -Fragment
    If ($arrSORepo.status -match "Critical") {
      $sorepoHead = $subHead01err
    } ElseIf ($arrSORepo.status -match "Warning|Unknown") {
      $sorepoHead = $subHead01war
    } ElseIf ($arrSORepo.status -match "OK") {
      $sorepoHead = $subHead01suc
    } Else {
      $sorepoHead = $subHead01
    }
    $bodySORepo = $sorepoHead + "Scale Out Repository Details" + $subHead02 + $bodySORepo
  }
}
   
$HTMLmessage = @" 
 <font face="Microsoft Tai le"> 
 <br /><br />
         <h1 style="background-color:powderblue;text-align: center"> Veeam Repo info</h1>
$bodyRepo
$bodySORepo
    <br /><br />
</font> 
<br> <br> 
<!--mce:0--> 
<body BGCOLOR=""white""> 
<br> <br>  </font> 
</body> 
"@  
 send-mailmessage -from $fromemail -to $users -subject "Veeam Repo info : $time" -BodyAsHTML -body $bodyRepo -priority High -smtpServer $server
Last edited by Natalia Lupacheva on Mar 10, 2021 10:31 am, edited 1 time in total.
Reason: added code formatting, please use [code] tag
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: My Veeam Report v9.5.1

Post by veremin »

Unfortunately, we cannot help you with re-writting the custom scripts that has been found on the internet, especially, when not much information is provided regarding the actual error or issue experienced.

Most likely, the script starts showing incorrect values due to the changes introduced in v11 to internal properties, such as CachedFreeSpace. Those changes are described in the thread referenced above. There you can also find a way to access required information in a different way. Also, you can see there an alternative script that provides the information you are after. So, kindly, take a look.

Thank you for understanding.
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Hi All,

At least someone helps me to get ScaleOut Repository free space and total space
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: My Veeam Report v9.5.1

Post by Natalia Lupacheva » 1 person likes this post

Hi Kalaimani,

does this solution work for you?
CachedFreeSpace and CachedTotalSpace were moved to another class and you need to use the described method to get these values on v11.

Thanks!
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Dear its works only for simple Repository not for ScaleOut Repository
Egor Yakovlev
Veeam Software
Posts: 2536
Liked: 680 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Location: Prague, Czech Republic
Contact:

Re: My Veeam Report v9.5.1

Post by Egor Yakovlev » 2 people like this post

It works for both...if you change 2 lines of the code as Oleg suggested, it works perfectly with all types of repositories with v11.

Code: Select all

# Get All Backup Repositories Advanced
[Array]$RepoList = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"} 
[Array]$ScaleOuts = Get-VBRBackupRepository -ScaleOut
if ($ScaleOuts) {
    foreach ($ScaleOut in $ScaleOuts) {
        $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
        foreach ($Extent in $Extents) {
            $RepoList = $RepoList + $Extent.repository
        }
    }
}
$RepoList | Select-Object Name, Path, `
@{Name="CachedTotalSpaceGB"; Expression= {[Math]::Round([Decimal]$_.GetContainer().CachedTotalSpace.InBytes/1GB,2)}}, `
@{Name="CachedFreeSpaceGB"; Expression= {[Math]::Round([Decimal]$_.GetContainer().CachedFreeSpace.InBytes/1GB,2)}} | Format-Table -AutoSize
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Thanks for your response and I really apologize for troubling you, but I don't have any other way to find the solution,

I have added some more filled but not able to get proper for "Scale Out Repository Name", "Member Repository Name" and " Free %"

Code: Select all

# Repository Free Space Remaining %
$repoCritical = 10
$repoWarn = 20
# Show Repository Info
$showRepo = $true
# Get All Backup Repositories Advanced
#[Array]$RepoList = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"} 
[Array]$ScaleOuts = Get-VBRBackupRepository -ScaleOut
if ($ScaleOuts) {
    foreach ($ScaleOut in $ScaleOuts) {
        $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
        foreach ($Extent in $Extents) {
            $RepoList = $RepoList + $Extent.repository
        }
    }
}
$RepoList | Select-Object Name, Path,Type, 
@{Name="Total (GB)"; Expression= {[Math]::Round([Decimal]$_.GetContainer().CachedTotalSpace.InBytes/1GB,2)}}, `
@{Name="Free (GB)"; Expression= {[Math]::Round([Decimal]$_.GetContainer().CachedFreeSpace.InBytes/1GB,2)}},
@{Name="Member Repository Name"; Expression = {$_.Target}},
@{Name="Max Tasks"; Expression = {$_.Options.MaxTaskCount}}, 
@{Name="Host"; Expression = {$_.Host.name}},
@{Name="Free (%)"; Expression = {$_.FreePercentage}},
@{Name="Status"; Expression = {
If ($_.GetContainer().CachedFreeSpace.InBytes -lt $repoCritical) {"Critical"}
ElseIf ($_.GetContainer().CachedFreeSpace.InBytes -eq 0) {"Warning"}
ElseIf ($_.GetContainer().CachedFreeSpace.InBytes -lt $repoWarn) {"Warning"}
ElseIf ($_.GetContainer().CachedFreeSpace.InBytes -eq "Unknown") {"Unknown"}
Else {"OK"}}
}
$bodySORepo = $RepoList  | Sort "Scale Out Repository Name", "Member Repository Name" | ConvertTo-HTML -Fragment
If ($arrSORepo.status -match "Critical") {
$sorepoHead = $subHead01err
} ElseIf ($arrSORepo.status -match "Warning|Unknown") {
$sorepoHead = $subHead01war
} ElseIf ($arrSORepo.status -match "OK") {
$sorepoHead = $subHead01suc
} Else {
$sorepoHead = $subHead01
}
$bodySORepo = $sorepoHead + "Scale Out Repository Details" + $subHead02 + $bodySORepo
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Dear All, can you check, if able to help me
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov » 5 people like this post

Hi,

Adjusted your code accordingly:

Code: Select all

 # Repository Free Space Remaining %
$repoCritical = 10
$repoWarn = 20
# Show Repository Info
$showRepo = $true
# Get All Backup Repositories Advanced
$repoList = @()
#[Array]$RepoList = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"} 
[Array]$ScaleOuts = Get-VBRBackupRepository -ScaleOut
if ($ScaleOuts) {
    foreach ($ScaleOut in $ScaleOuts) {
        $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
        foreach ($Extent in $Extents) {
        $total = [Math]::Round([Decimal]$extent.Repository.GetContainer().CachedTotalSpace.InBytes/1GB,2)
        $free = [Math]::Round([Decimal]$extent.Repository.GetContainer().CachedFreeSpace.InBytes/1GB,2)
        $freePcnt = [Math]::Round($free / ($total / 100), 2)
        If ($extent.Repository.GetContainer().CachedFreeSpace.InBytes -lt $repoCritical) {$status = "Critical"}
        ElseIf ($extent.Repository.GetContainer().CachedFreeSpace.InBytes -eq 0) {$status = "Warning"}
        ElseIf ($extent.Repository.GetContainer().CachedFreeSpace.InBytes -lt $repoWarn) {$status = "Warning"}
        ElseIf ($extent.Repository.GetContainer().CachedFreeSpace.InBytes -eq "Unknown") {$status = "Unknown"}
        Else {$status = "OK"}
        $repo = $Extent.repository | Select-Object @{Name="ScaleOutName";Expression={$ScaleOut.Name}}, Path,Type, 
@{Name="Total (GB)"; Expression= {$total}}, `
@{Name="Free (GB)"; Expression= {$free}},
@{Name="ExtentName"; Expression = {$_.Name}},
@{Name="Max Tasks"; Expression = {$_.Options.MaxTaskCount}}, 
@{Name="Host"; Expression = {$_.Host.name}},
@{Name="Free (%)"; Expression = {$freePcnt}},
@{Name="Status"; Expression = {$status}}
        $repoList += $repo
}
}
}

$bodySORepo = $RepoList  | Sort "ScaleOutName", "ExtentName" | ConvertTo-HTML -Fragment
If ($arrSORepo.status -match "Critical") {
$sorepoHead = $subHead01err
} ElseIf ($arrSORepo.status -match "Warning|Unknown") {
$sorepoHead = $subHead01war
} ElseIf ($arrSORepo.status -match "OK") {
$sorepoHead = $subHead01suc
} Else {
$sorepoHead = $subHead01
}

$bodySORepo = $sorepoHead + "Scale Out Repository Details" + $subHead02 + $bodySORepo 

Few comments:
- If you want granular data on each extent, you'd need to build a new hash table every loop, so I moved it to the loop from the global scope.
- Try calling methods as explicitly as possible when constructing expressions.
- Assign complex expressions to a separate variable before constructing a hashtable.
- You'd need to count Free % from total and free space properties.

And a logical error:
- You set default warning and error values for space left in percents, but in your conditionals you validate if real values in bytes are equal to them. You might need to convert real values to percents before validation. Otherwise, you are bound to see errors and warnings in status property only on 10-20 bytes of space left.

Thanks,
Oleg
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Thanks Oleg. I'm using the same script to get the Scale-Out Repository Details it's working without any issue but networking for the repository, I need you support again
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Thanks, Oleg. I'm using the same script to get the Scale-Out Repository Details it's working without any issue but not working for the simple repository, I need your support again
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: My Veeam Report v9.5.1

Post by Natalia Lupacheva »

Hi Kalaimani,

Please share the details of the issue you've faced with the script.
If it's not about the same report, I would recommend opening a new thread to keep different issues in different topics.
If it's about the same script, it's better to continue here.

Anyway, it's hard to guess what happened without any details, so please clarify what happened.
Please note we do not write the scripts here on forums for whatever you need. We try to help with the existing ones when it's possible.

Thanks!
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: My Veeam Report v9.5.1

Post by oleg.feoktistov »

@kalaimani53,

I would like to add to Natalia's comment. We provide support with scripts on our best effort. The script should work perfectly with simple repositories. You just need to copy the existing loop and adapt it to simple repos. Everything else is in the script already.

Thanks,
Oleg
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Thanks, Oleg. yes, I'm trying to adapt the existing script but getting some error.

Code: Select all

# Email configuration
$sendEmail = $true
$emailHost = ""
$emailPort = 25
$emailEnableSSL = $false
$emailUser = ""
$emailPass = ""
$emailFrom = ""
$emailTo = ""
 
 # Repository Free Space Remaining %
$repoCritical = 10
$repoWarn = 20
# Show Repository Info
$showRepo = $true

$RepoLista = Get-VBRBackupRepository | Where-Object {$_.Type -ne "SanSnapshotOnly"} 

# Get Repository Info

$bodyRepo = $null
If ($showRepo) {

        foreach ($Extent in $RepoLista) {
        $total = [Math]::Round([Decimal]$extent.GetContainer().CachedTotalSpace.InBytes/1GB,2)
        $free = [Math]::Round([Decimal]$extent.GetContainer().CachedFreeSpace.InBytes/1GB,2)
        $freePcnt = [Math]::Round($free / ($total / 100), 2)
     

$repo = $Extent| Select-Object @{Name="Repository Name"; Expression = {$_.Name}}, Path,Type, 

@{Name="Max Tasks"; Expression = {$_.Options.MaxTaskCount}}, 
@{Name="Host"; Expression = {$_.Host.name}},
@{Name="Total (GB)"; Expression= {$total}}, `
@{Name="Free (GB)"; Expression= {$free}},
@{Name="Free (%)"; Expression = {$freePcnt}},
@{Name="Status"; Expression = {$status}}

   If ($extent.GetContainer().CachedFreeSpace.InBytes -lt $repoCritical) {$status = "Critical"}
        ElseIf ($extent.GetContainer().CachedFreeSpace.InBytes -eq 0) {$status = "Warning"}
        ElseIf ($extent.GetContainer().CachedFreeSpace.InBytes -lt $repoWarn) {$status = "Warning"}
        ElseIf ($extent.GetContainer().CachedFreeSpace.InBytes -eq "Unknown") {$status = "Unknown"}
        Else {$status = "OK"}
 $repoList +=$repo

    $bodyRepo = $repoList| Sort "Repository Name" | ConvertTo-HTML -Fragment       
    If ($repoList.status -match "Critical") {
      $repoHead = $subHead01err
    } ElseIf ($repoList.status -match "Warning|Unknown") {
      $repoHead = $subHead01war
    } ElseIf ($repoList.status -match "OK") {
      $repoHead = $subHead01suc
    } Else {
      $repoHead = $subHead01
    }    
    $bodyRepo = $repoHead + "Repository Details" + $subHead02 + $bodyRepo
  }
  }

   $bodyRepo

    # Get Scale Out Repository Info
$repoListSo = Get-VBRBackupRepository -ScaleOut
$bodySORepo = $null
If ($showRepo) {
  If ($repoListSo -ne $null) {
   
if ($repoListSo) {
    foreach ($ScaleOut in $repoListSo) {
        $Extents = Get-VBRRepositoryExtent -Repository $ScaleOut
        foreach ($Extent in $Extents) {
        $total = [Math]::Round([Decimal]$extent.Repository.GetContainer().CachedTotalSpace.InBytes/1GB,2)
        $free = [Math]::Round([Decimal]$extent.Repository.GetContainer().CachedFreeSpace.InBytes/1GB,2)
        $freePcnt = [Math]::Round($free / ($total / 100), 2)
        If ($extent.Repository.GetContainer().CachedFreeSpace.InBytes -lt $repoCritical) {$status = "Critical"}
        ElseIf ($extent.Repository.GetContainer().CachedFreeSpace.InBytes -eq 0) {$status = "Warning"}
        ElseIf ($extent.Repository.GetContainer().CachedFreeSpace.InBytes -lt $repoWarn) {$status = "Warning"}
        ElseIf ($extent.Repository.GetContainer().CachedFreeSpace.InBytes -eq "Unknown") {$status = "Unknown"}
        Else {$status = "OK"}
        $repo = $Extent.repository | Select-Object @{Name="ScaleOutName";Expression={$ScaleOut.Name}},@{Name="ExtentName"; Expression = {$_.Name}}, Path,Type, 

@{Name="Host"; Expression = {$_.Host.name}},
@{Name="Max Tasks"; Expression = {$_.Options.MaxTaskCount}}, 

@{Name="Total (GB)"; Expression= {$total}}, `
@{Name="Free (GB)"; Expression= {$free}},
@{Name="Free (%)"; Expression = {$freePcnt}},
@{Name="Status"; Expression = {$status}}
        $repoLists += $repo
}


$bodySORepo = $RepoLists  | Sort "ScaleOutName", "ExtentName" | ConvertTo-HTML -Fragment
If ($RepoLists.status -match "Critical") {
$sorepoHead = $subHead01err
} ElseIf ($RepoLists.status -match "Warning|Unknown") {
$sorepoHead = $subHead01war
} ElseIf ($RepoLists.status -match "OK") {
$sorepoHead = $subHead01suc
} Else {
$sorepoHead = $subHead01
}

$bodySORepo = $sorepoHead + "Scale Out Repository Details" + $subHead02 + $bodySORepo 
}
}
}}


$HTMLmessage = @" 
 <font face="Microsoft Tai le"> 
 <br /><br />
         <h1 style="background-color:powderblue;text-align: center"> Veeam Repo info</h1>

 $bodyRepo
    <br /><br />

    $bodySORepo
</font> 
<br> <br> 
<!--mce:0--> 
<body BGCOLOR=""white""> 
<br> <br>  </font> 
</body> 
"@  
 send-mailmessage -from $emailFrom -to $emailTo -subject "Veeam Repo info : $time" -BodyAsHTML -body   $HTMLmessage -priority High -smtpServer $emailHost
 
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: My Veeam Report v9.5.1

Post by veremin »

Unfortunately, the team behind this forum is unable to provide custom development services like adjusting sample scripts to different environments and needs. I suggest you get help from a certified Veeam implementation consultant for this > Find a VASP.

Thanks!
kalaimani53
Enthusiast
Posts: 25
Liked: 1 time
Joined: Jul 14, 2020 1:43 pm
Full Name: Kalaimani
Contact:

Re: My Veeam Report v9.5.1

Post by kalaimani53 »

Thanks, Veeam Team,

You guys helped a lot(especially for Oleg). but not getting what I'm looking for. this is not that critical to reaching out the professional services. I'll work on this. thanks

Regards
Kalai
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests