Public/Storage/Add-VmsArchiveStorage.ps1
function Add-VmsArchiveStorage { <# .SYNOPSIS Adds a new Archive Storage configuration to an existing live recording storage configuration. .PARAMETER Storage Specifies the Recording Server to which the storage configuration should be added. This should be a RecordingServer object such as that returned by the Get-RecordingServer cmdlet. .PARAMETER Name Specifies the name of the storage configuration. .PARAMETER Description Specifies the optional description of the storage configuration. .PARAMETER Path Specifies the path under which the new storage folder will be created on the Recording Server or UNC path. .PARAMETER Retention Specifies the retention, as a [timespan], after which the recordings will be deleted, or archived if you choose to add an archive storage to the new storage configuration after it is created. The minimum timespan is 60 minutes, and the maximum is 2147483647 minutes. .PARAMETER MaximumSizeMB Specifies the maximum size for the live storage before data should be archived or deleted. .PARAMETER ReduceFramerate Specifies that the framerate should be reduced when taking recordings from the previous live/archive storage area WARNING: Framerate reduction when the codec is anything besides MJPEG results in keyframes only, which is usually 1 FPS. .PARAMETER TargetFramerate Specifies the desired framerate for recordings stored in this archive storage area. WARNING: Framerate reduction when the codec is anything besides MJPEG results in keyframes only, which is usually 1 FPS. .EXAMPLE PS C:\> Get-RecordingServer | Get-VmsArchiveStorage -Name '90 Day Retention' | Add-VmsArchiveStorage -Name 'Last 80 Days' -Path C:\MediaDatabase\ -Retention (New-Timespan -Days 90) -MaximumSizeMB (10TB/1MB) Adds an archive to every storage configuration on every recording server where the name is '90 Day Retention'. The storage and archive names imply that the first 10 days are in the live drive, and the archive contains the last 80 days. The retention of the archive is set to 90 days because that value specifies how old the recordings in that container must be before they are eligible for deleting or archiving to the next archive in the chain. We use the helpful TB and MB multipliers to specify the maximum size of 10TB. #> [CmdletBinding(SupportsShouldProcess)] [OutputType([VideoOS.Platform.ConfigurationItems.ArchiveStorage])] param( [Parameter(Mandatory, ValueFromPipeline)] [VideoOS.Platform.ConfigurationItems.Storage] $Storage, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $Name, [Parameter()] [string] $Description, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $Path, [Parameter()] [ValidateScript({ if ($_ -lt [timespan]::FromMinutes(60)) { throw "Retention must be greater than or equal to one hour" } if ($_ -gt [timespan]::FromMinutes([int]::MaxValue)) { throw "Retention must be less than or equal to $([int]::MaxValue) minutes." } $true })] [timespan] $Retention, [Parameter(Mandatory)] [ValidateRange(1, [int]::MaxValue)] [int] $MaximumSizeMB, [Parameter()] [switch] $ReduceFramerate, [Parameter()] [ValidateRange(0.00028, 100)] [double] $TargetFramerate = 5 ) process { $archiveFolder = $Storage.ArchiveStorageFolder if ($PSCmdlet.ShouldProcess("Recording storage '$($Storage.Name)'", "Add new archive storage named '$($Name)' with retention of $($Retention.TotalHours) hours and a maximum size of $($MaximumSizeMB) MB")) { try { $taskInfo = $archiveFolder.AddArchiveStorage($Name, $Description, $Path, $TargetFrameRate, $Retention.TotalMinutes, $MaximumSizeMB) if ($taskInfo.State -ne [videoos.platform.configurationitems.stateenum]::Success) { Write-Error -Message $taskInfo.ErrorText return } $archive = [VideoOS.Platform.ConfigurationItems.ArchiveStorage]::new((Get-ManagementServer).ServerId, $taskInfo.Path) if ($ReduceFramerate) { $invokeInfo = $archive.SetFramerateReductionArchiveStorage() $invokeInfo.SetProperty('FramerateReductionEnabled', 'True') [void]$invokeInfo.ExecuteDefault() } $storage.ClearChildrenCache() Write-Output $archive } catch { Write-Error $_ return } } } } |