MilestoneSystemsInc / PowerShellSamples

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

Get-VmsCameraDiskUsage throws a large series of errors #127

Closed jw15851 closed 4 months ago

jw15851 commented 4 months ago

updated PSTools Ran PShell as admin, on a machine with Management Client installed with the DLL at the expected path. loaded script from GitHub: Get-VmsCameraDiskUsage.ps1 issued: Get-Hardware | Get-Camera | Get-VmsCameraDiskUsage | Out-GridView command The result is below:

PS C:\WINDOWS\system32\WindowsPowerShell\v1.0> C:\Get-VmsCameraDiskUsage.ps1

PS C:\WINDOWS\system32\WindowsPowerShell\v1.0> Connect-ManagementServer -ShowDialog

PS C:\WINDOWS\system32\WindowsPowerShell\v1.0> Get-Hardware | Get-Camera | Get-VmsCameraDiskUsage | Out-GridView
WARNING: The default behavior of Get-VmsCamera is to return only enabled devices, but while using the Get-Camera alias, the behavior matches the original Get-Camera comma
nd and returns all cameras, including disabled cameras.
'DatabaseOperationType' is a ReadOnly property.
At C:\Get-VmsCameraDiskUsage.ps1:56 char:9
+         $cmd.DatabaseOperationType = [VideoOS.Common.Integration.Comm ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The property '_deviceIds' cannot be found on this object. Verify that the property exists and can be set.
At C:\Get-VmsCameraDiskUsage.ps1:58 char:9
+         $cmd._deviceIds = $deviceIds
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Get-IServerProxyService : The term 'Get-IServerProxyService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.
At C:\Get-VmsCameraDiskUsage.ps1:61 char:16
+         $svc = Get-IServerProxyService
+                ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-IServerProxyService:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:63 char:9
+         $svc.SendCommand($proxyId, $cmd)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:65 char:9
+         $response = $svc.GetResponses($proxyId, (New-TimeSpan -Second ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

WARNING: The default behavior of Get-VmsCamera is to return only enabled devices, but while using the Get-Camera alias, the behavior matches the original Get-Camera comma
nd and returns all cameras, including disabled cameras.
'DatabaseOperationType' is a ReadOnly property.
At C:\Get-VmsCameraDiskUsage.ps1:56 char:9
+         $cmd.DatabaseOperationType = [VideoOS.Common.Integration.Comm ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The property '_deviceIds' cannot be found on this object. Verify that the property exists and can be set.
At C:\Get-VmsCameraDiskUsage.ps1:58 char:9
+         $cmd._deviceIds = $deviceIds
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Get-IServerProxyService : The term 'Get-IServerProxyService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.
At C:\Get-VmsCameraDiskUsage.ps1:61 char:16
+         $svc = Get-IServerProxyService
+                ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-IServerProxyService:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:63 char:9
+         $svc.SendCommand($proxyId, $cmd)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:65 char:9
+         $response = $svc.GetResponses($proxyId, (New-TimeSpan -Second ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

'DatabaseOperationType' is a ReadOnly property.
At C:\Get-VmsCameraDiskUsage.ps1:56 char:9
+         $cmd.DatabaseOperationType = [VideoOS.Common.Integration.Comm ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The property '_deviceIds' cannot be found on this object. Verify that the property exists and can be set.
At C:\Get-VmsCameraDiskUsage.ps1:58 char:9
+         $cmd._deviceIds = $deviceIds
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Get-IServerProxyService : The term 'Get-IServerProxyService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.
At C:\Get-VmsCameraDiskUsage.ps1:61 char:16
+         $svc = Get-IServerProxyService
+                ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-IServerProxyService:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:63 char:9
+         $svc.SendCommand($proxyId, $cmd)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:65 char:9
+         $response = $svc.GetResponses($proxyId, (New-TimeSpan -Second ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

WARNING: The default behavior of Get-VmsCamera is to return only enabled devices, but while using the Get-Camera alias, the behavior matches the original Get-Camera comma
nd and returns all cameras, including disabled cameras.
'DatabaseOperationType' is a ReadOnly property.
At C:\Get-VmsCameraDiskUsage.ps1:56 char:9
+         $cmd.DatabaseOperationType = [VideoOS.Common.Integration.Comm ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The property '_deviceIds' cannot be found on this object. Verify that the property exists and can be set.
At C:\Get-VmsCameraDiskUsage.ps1:58 char:9
+         $cmd._deviceIds = $deviceIds
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Get-IServerProxyService : The term 'Get-IServerProxyService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.
At C:\Get-VmsCameraDiskUsage.ps1:61 char:16
+         $svc = Get-IServerProxyService
+                ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-IServerProxyService:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:63 char:9
+         $svc.SendCommand($proxyId, $cmd)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:65 char:9
+         $response = $svc.GetResponses($proxyId, (New-TimeSpan -Second ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

'DatabaseOperationType' is a ReadOnly property.
At C:\Get-VmsCameraDiskUsage.ps1:56 char:9
+         $cmd.DatabaseOperationType = [VideoOS.Common.Integration.Comm ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The property '_deviceIds' cannot be found on this object. Verify that the property exists and can be set.
At C:\Get-VmsCameraDiskUsage.ps1:58 char:9
+         $cmd._deviceIds = $deviceIds
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Get-IServerProxyService : The term 'Get-IServerProxyService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.
At C:\Get-VmsCameraDiskUsage.ps1:61 char:16
+         $svc = Get-IServerProxyService
+                ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-IServerProxyService:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:63 char:9
+         $svc.SendCommand($proxyId, $cmd)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:65 char:9
+         $response = $svc.GetResponses($proxyId, (New-TimeSpan -Second ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

'DatabaseOperationType' is a ReadOnly property.
At C:\Get-VmsCameraDiskUsage.ps1:56 char:9
+         $cmd.DatabaseOperationType = [VideoOS.Common.Integration.Comm ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The property '_deviceIds' cannot be found on this object. Verify that the property exists and can be set.
At C:\Get-VmsCameraDiskUsage.ps1:58 char:9
+         $cmd._deviceIds = $deviceIds
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Get-IServerProxyService : The term 'Get-IServerProxyService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.
At C:\Get-VmsCameraDiskUsage.ps1:61 char:16
+         $svc = Get-IServerProxyService
+                ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-IServerProxyService:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:63 char:9
+         $svc.SendCommand($proxyId, $cmd)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:65 char:9
+         $response = $svc.GetResponses($proxyId, (New-TimeSpan -Second ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

'DatabaseOperationType' is a ReadOnly property.
At C:\Get-VmsCameraDiskUsage.ps1:56 char:9
+         $cmd.DatabaseOperationType = [VideoOS.Common.Integration.Comm ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The property '_deviceIds' cannot be found on this object. Verify that the property exists and can be set.
At C:\Get-VmsCameraDiskUsage.ps1:58 char:9
+         $cmd._deviceIds = $deviceIds
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Get-IServerProxyService : The term 'Get-IServerProxyService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.
At C:\Get-VmsCameraDiskUsage.ps1:61 char:16
+         $svc = Get-IServerProxyService
+                ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-IServerProxyService:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:63 char:9
+         $svc.SendCommand($proxyId, $cmd)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

**[[  long section cut out because GitHub isn't letting me use enough characters  ]]**

Get-IServerProxyService : The term 'Get-IServerProxyService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling 
of the name, or if a path was included, verify that the path is correct and try again.
At C:\Get-VmsCameraDiskUsage.ps1:61 char:16
+         $svc = Get-IServerProxyService
+                ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-IServerProxyService:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:63 char:9
+         $svc.SendCommand($proxyId, $cmd)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Get-VmsCameraDiskUsage.ps1:65 char:9
+         $response = $svc.GetResponses($proxyId, (New-TimeSpan -Second ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

PS C:\WINDOWS\system32\WindowsPowerShell\v1.0> 
Tarterman commented 4 months ago

Where are you getting the Get-VmsDiskUsage.ps1 script from? I'm not seeing it as part of the samples (unless I'm missing it).

jw15851 commented 4 months ago

https://github.com/MilestoneSystemsInc/PowerShellSamples/blob/main/Samples/Reporting/Get-VmsCameraDiskUsage.ps1

On Fri, Apr 19, 2024 at 4:21 PM Jared Tarter @.***> wrote:

Where are you getting the Get-VmsDiskUsage.ps1 script from? I'm not seeing it as part of the samples (unless I'm missing it).

— Reply to this email directly, view it on GitHub https://github.com/MilestoneSystemsInc/PowerShellSamples/issues/127#issuecomment-2067297876, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJVG7MSPMTNZ64AYV5JWJQTY6GDE7AVCNFSM6AAAAABGLYFDT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRXGI4TOOBXGY . You are receiving this because you authored the thread.Message ID: @.***>

Tarterman commented 4 months ago

OK, it is what I was suspecting. This script is an older one that used Get-IServerProxyService. That has been removed (about 3 years ago) from MilestonePSTools because it was using unsupported APIs that could (and did) change from version to version making the function completely unreliable.

That script would return something like this for each camera: image

The "AvailableSpace" was the total amount of space across any live and archive databases that the camera was assigned to. This is one we could potentially look at updating with supported features but, for now, I'd suggest Get-VmsCameraReport. It obviously returns more data and takes longer but it can be filtered down to return less data (but it won't decrease the time). For example, they could run this command which returns the same information except for the total storage available across the live and archive databases.

Get-VmsCameraReport | Select-Object RecorderName, HardwareName, Name, UsedSpaceInGB, IsStarted | Out-GridView

That will return this: image

Tarterman commented 4 months ago

I updated the Get-VmsCameraDiskUsage function to use supported functionality.