Skip to content

Instantly share code, notes, and snippets.

@joshooaj
Last active September 30, 2021 22:30
Show Gist options
  • Select an option

  • Save joshooaj/c35f625e6f8f8d5bf230a69f3ad28099 to your computer and use it in GitHub Desktop.

Select an option

Save joshooaj/c35f625e6f8f8d5bf230a69f3ad28099 to your computer and use it in GitHub Desktop.
Gets a [timespan] representing the storage retention for the specified Milestone XProtect recording server storage configuration
function Get-VmsStorageRetention {
<#
.SYNOPSIS
Gets a [timespan] representing the storage retention for the specified storage configuration
.DESCRIPTION
A Milestone Storage object represents both the overall storage configuration and the live
storage information for that storage configuration. It has ArchiveStorage child items for each
archive path associated with that storage configuration. To determine the retention for the
whole storage configuration, you need to find the largest "RetainMinutes" value between the
live recording path and all the optional archive storage paths.
This function saves the step of checking whether archives exist and finding the archive child
item with the longest retention.
The value returned represents the maximum age of data before it will be deleted. The only
exception is if you have used the evidence lock feature which can tag video with custom
retention policies and even keep video indefinitely.
.PARAMETER Storage
Specifies the the storage object from which to return the maximum retention value. Use Get-VmsStorage to acquire a Storage object.
.EXAMPLE
PS C:\> Get-RecordingServer -Name Test | Get-VmsStorage | Foreach-Object { [pscustomobject]@{ Storage = $_.Name; Retention = ($_ | Get-VmsStorageRetention).TotalDays } }
Gets all storage configurations associated with the Recording Server named "Test" and returns the storage names and the maximum retention value in days.
#>
[CmdletBinding()]
[OutputType([timespan])]
param(
[Parameter(Mandatory, ValueFromPipeline)]
[VideoOS.Platform.ConfigurationItems.Storage]
$Storage
)
process {
$retention = [int]$Storage.RetainMinutes
foreach ($archive in $Storage.ArchiveStorageFolder.ArchiveStorages) {
if ($archive.RetainMinutes -gt $retention) {
$retention = $archive.RetainMinutes
}
}
Write-Output ([timespan]::FromMinutes($retention))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment