Skip to content

Instantly share code, notes, and snippets.

@joshooaj
Created May 23, 2021 18:07
Show Gist options
  • Save joshooaj/0deedd88dd49b57e2fc188b8b3b0c7c2 to your computer and use it in GitHub Desktop.
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
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
@joshooaj
Copy link
Author

The output of this on my test system looks like...

Recorder              HostName                  Id                                   ErrorCount ErrorOverflow ErrorWritingGop ErrorNoConnection ErrorNotLicensed
--------              --------                  --                                   ---------- ------------- --------------- ----------------- ----------------
Recorder 1 Instance 1 10.0.0.119                63666E84-DF7D-43F2-9B8D-5FE92F227A1C        249           249               6                 0                0
Recorder 2            ec2amaz-018nssj.lab.local 97CFA42E-CE08-4E23-A4C1-0DA0F0CF5DCB          1             0               0                 1                0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment