Public/Tools/Select-Camera.ps1
function Select-Camera { <# .SYNOPSIS Offers a UI dialog for selecting items, similar to the item selection interface in Management Client. .DESCRIPTION This cmdlet implements the VideoOS.Platform.UI.ItemPickerUserControl in a custom form to allow the user to select one or more items of any kind using a friendly and customizable user interface. .Parameter Title Specifies the text in the title-bar of the Item Picker window. The default is "Select Camera(s)". .Parameter SingleSelect The ItemPicker allows for multiple items by default. Supply this parameter to force selection of a single item. .Parameter AllowFolders Device groups are considered folders and are not selectable by default. To allow for selecting many items with one click, include this parameter. Consider using this with the FlattenOutput switch unless you specifically need to select a folder item instead of it's child items. .Parameter AllowServers Supply this switch to enable selection of servers. You might choose to do this if you want to select Recording Servers, or you want to select all child items, such as cameras, from a server. Consider using this with the FlattenOutput switch unless you specifically need to select a server item instead of it's child items. .Parameter RemoveDuplicates Automatically remove duplicate cameras from the output before outputing them. Useful when you select a folder which may have the same cameras in more than one child folder. .Parameter OutputAsItem Output cameras as VideoOS.Platform.Item objects instead of converting them to Configuration API Camera objects. Depending on your needs, it may be more performant to use OutputAsItem. For example, if you are using a cmdlet like Get-Snapshot, you can extract the $item.FQID.ObjectId and provide that Guid in the CameraId parameter to avoid an unnecessary conversion between Item, ConfigurationItem, and back again. .EXAMPLE PS C:\> Get-BankTable C:\MediaDatabase\4344cd14-0b12-4c18-8677-5d263c140af4 -DeviceId "94275fef-b977-43f6-bf78-210c615b2967" | Copy-Item -Destination C:\Temp -Container -Recurse -Force Copy all media database tables for device with ID 94275fef-b977-43f6-bf78-210c615b2967 to C:\Temp #> [CmdletBinding()] param( [Parameter()] [string] $Title = "Select Camera(s)", [Parameter()] [switch] $SingleSelect, [Parameter()] [switch] $AllowFolders, [Parameter()] [switch] $AllowServers, [Parameter()] [switch] $RemoveDuplicates, [Parameter()] [switch] $OutputAsItem ) process { $items = Select-VideoOSItem -Title $Title -Kind ([VideoOS.Platform.Kind]::Camera) -AllowFolders:$AllowFolders -AllowServers:$AllowServers -SingleSelect:$SingleSelect -FlattenOutput $processed = @{} if ($RemoveDuplicates) { foreach ($item in $items) { if ($processed.ContainsKey($item.FQID.ObjectId)) { continue } $processed.Add($item.FQID.ObjectId, $null) if ($OutputAsItem) { Write-Output $item } else { Get-Camera -Id $item.FQID.ObjectId } } } else { if ($OutputAsItem) { Write-Output $items -NoEnumerate } else { Write-Output ($items | ForEach-Object { Get-Camera -Id $_.FQID.ObjectId }) } } } } |