MilestoneSystemsInc / PowerShellSamples

A collection of samples for managing your Milestone XProtect VMS using MilestonePSTools in PowerShell
https://www.milestonepstools.com
MIT License
37 stars 12 forks source link

Get-VMSCameraReport Generates non-terminating error when recording server has no cameras on it. #157

Open davidfrankks opened 1 month ago

davidfrankks commented 1 month ago

When running Get-VMSCameraReport against a cluster of recording servers, the module generates the following none terminating error. Get-VmsCameraReport : Exception calling "GetCurrentDeviceStatus" with "2" argument(s): "Error processing message"

Scenario: We have multi node servers where 1 node acts as the management server as well as recording server, and then multiple recording servers tied to that management node. In some cases we have to evacuate a single recording server to change out disk drives or do other maintenance. When that happens and no cameras exist on the node, the error occurs. This can be recreated by doing a get-vmscamerareport against a server with no hardware devices, then add a universal device, just as a placeholder and the error goes away. If you then disabled that placeholder device the error returns as the recording server has no live hardware devices on it.

Verbose output:
Connect-ManagementServer -ShowDialog
    $X = Get-VmsCameraReport -ErrorAction Stop -Verbose
Disconnect-ManagementServer
VERBOSE: Environment variable "MILESTONEPSTOOLS_PROXYCOUNT" unset or not a valid integer. Defaulting to 1 WCF proxy client per client type.
VERBOSE: Creating new WCF channel of type VideoOS.Common.Proxy.Server.WCF.IServerCommandService
VERBOSE: Listing all recording servers
VERBOSE: Calling Get-ItemState
VERBOSE: Starting FillChildren threadjob
VERBOSE: Starting GetVideoDeviceStatistics threadjob
VERBOSE: Starting GetCurrentDeviceStatus threadjob
VERBOSE: Receiving results of FillChildren threadjob
VERBOSE: Receiving results of GetVideoDeviceStatistics threadjobs
VERBOSE: Receiving results of GetCurrentDeviceStatus threadjobs
Get-VmsCameraReport : Exception calling "GetCurrentDeviceStatus" with "2" argument(s): "Error processing message"
At line:7 char:10
+     $X = Get-VmsCameraReport -ErrorAction Stop -Verbose
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-VmsCameraReport

The variable of $X still gets populated properly with the data from the other recording servers, but generates the error.

davidfrankks commented 1 month ago

It appears this has been resolved in the latest versions of MilestonePSTools. For anyone else with this issue, I updated milestonepstools and forced it to use the most recent version for testing.

Install-module MilestonePSTools -SkipPublisherCheck -Force Import-Module MilestonePSTools -RequiredVersion 24.1.30