Skip to content

Instantly share code, notes, and snippets.

@joshooaj
Last active September 12, 2024 23:14
Show Gist options
  • Save joshooaj/a2aad6adbc07ec2717d5b5f65c315e7a to your computer and use it in GitHub Desktop.
Save joshooaj/a2aad6adbc07ec2717d5b5f65c315e7a to your computer and use it in GitHub Desktop.
Discover cameras that are NOT in a view
function Get-CamerasThatArentInAView {
[CmdletBinding()]
param ()
process {
$camerasInViews = @{}
$publicViewGroups = Get-VmsViewGroup | Where-Object Name -ne 'Private'
$views = $publicViewGroups | Get-VmsViewGroup -Recurse | Get-VmsView
foreach ($view in $views) {
foreach ($item in $view.ViewItemChildItems) {
$definition = [xml]$item.ViewItemDefinitionXml
if ($definition.viewitem.type -notmatch 'CameraViewItem') {
continue
}
$camerasInViews[$definition.viewitem.iteminfo.cameraid] = $null
}
}
Get-VmsCamera | Where-Object { !$camerasInViews.ContainsKey($_.Id) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment