Created
May 23, 2021 18:07
-
-
Save joshooaj/0deedd88dd49b57e2fc188b8b3b0c7c2 to your computer and use it in GitHub Desktop.
Get current device status for all cameras from all recording servers and produce a table of Recording Servers with the number of cameras having errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-DeviceStatusReport { | |
$cameraKind = Get-Kind -List | Where-Object DisplayName -eq 'Camera' | Select-Object -ExpandProperty Kind | |
$groupedCameras = Get-PlatformItem -Kind $cameraKind | Select-Object @{Name='RecorderId'; Expression={$_.FQID.ServerId.Id}}, @{Name='CameraId'; Expression={$_.FQID.ObjectId}} | Group-Object RecorderId | |
foreach ($group in $groupedCameras) { | |
$recorder = Get-RecordingServer -Id $group.Name | |
try { | |
$svc = Get-RecorderStatusService2 -RecordingServer $recorder | |
$cameraStatusArray = $svc.GetCurrentDeviceStatus((Get-Token), $group.Group.CameraId).CameraDeviceStatusArray | |
[pscustomobject]@{ | |
Recorder = $recorder.Name | |
HostName = $recorder.HostName | |
Id = $recorder.Id | |
ErrorCount = ($cameraStatusArray | Where-Object Error).Count | |
ErrorOverflow = ($cameraStatusArray | Where-Object ErrorOverflow).Count | |
ErrorWritingGop = ($cameraStatusArray | Where-Object ErrorWritingGop).Count | |
ErrorNoConnection = ($cameraStatusArray | Where-Object ErrorNoConnection).Count | |
ErrorNotLicensed = ($cameraStatusArray | Where-Object ErrorNotLicensed).Count | |
} | |
} | |
finally { | |
$svc.Dispose() | |
} | |
} | |
} | |
Get-DeviceStatusReport | Format-Table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The output of this on my test system looks like...