PowerShell script exchange
Post Reply
aurelien-beneteau
Veeam Software
Posts: 46
Liked: 4 times
Joined: May 16, 2021 8:38 pm
Full Name: Aurelien Beneteau
Contact:

Veeam Powershell for cashback

Post by aurelien-beneteau »

Hi,
We protect VMware vSphere, Miscrosoft Hyper-V, Nutanix AHV and Windows & Linux servers using agents.
We would like to extract chargeback information, so the goal is to have a one-month schedule.
Based on this script : https://github.com/smitmartijn/public-p ... bSizes.ps1, we extracted the storage information to do the chargeback.
Perfect but can you help us to find more details about the command GetAllStorages() ? What are the available parameters ? We don't find details.

In addition, we would like to have one-month schedule for chargeback? How to get this information? We were thinking of Get-Date command but not sure it's the solution.
BR
Aurélien
david.domask
VeeaMVP
Posts: 1007
Liked: 275 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Veeam Powershell for cashback

Post by david.domask » 1 person likes this post

Hey @aurelien-beneteau,

First, though I doubt I need to inform, remember this is an unsupported .NET method, and these should not be relied on in scripts as they can and do frequently change.

GetAllStorages() and its sibling GetAllChildrenStorages() accept no arguments, and from my testing, as of v10 you want to use GetAllChildrenStorages(); the first method doesn't seem to return outside of Hypervisor backups (read: VMware and HyperV) and _some_ agent backups (I did not dig deep, but for my custom private scripts, I use GetAllChildrenStorages())

For getting a specific month, you can use the CreationTime property of the storages returned and add some code like:

Code: Select all

		$StartPeriod = Get-Date -Month $MonthForReview -Day 1 -Hour 0 -Minute 0 -Second 0
		$EndPeriod = $StartPeriod.AddMonths(1).AddSeconds(-1)
I use this in a scheduling script outside of Veeam; my script accepts an [int]$MonthForReview as a parameter and it warns users to enter a value 1-12, then you can just do something like:

Code: Select all

$Storages | Where-Object {$_.CreationTime -ge $StartPeriod -And $_.CreationTime -le $EndPeriod}
Does this help?
David Domask | Director: Customer Care | Veeam Technical Support
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests