Skip to content

Invoke-IcingaCheckHyperVSnapshot - You cannot call a method on a null-valued expression. #77

Closed
@Aleksey-Maksimov

Description

@Aleksey-Maksimov

Hello.

The snapshot checking plugin Invoke-IcingaCheckHyperVSnapshot works fine if all virtual machines are included in the scan

Invoke-IcingaCheckHyperVSnapshot -Verbosity 2 -CountSnapshotWarning 0 -NoPerfData -AvoidEmptyCheck

[OK] VM Snapshots: 4 Ok
\_ [OK] KOM-WS41
   \_ [OK] KOM-WS41
      \_ [OK] No snapshots created: 0
\_ [OK] KOM-WS42
   \_ [OK] KOM-WS42
      \_ [OK] No snapshots created: 0
\_ [OK] KOM-WS43
   \_ [OK] KOM-WS43
      \_ [OK] No snapshots created: 0
\_ [OK] KOM-WS44
   \_ [OK] KOM-WS44
      \_ [OK] No snapshots created: 0

Also, the plugin works fine if we add the -ExcludeVms filter and a certain part of the virtual machines is included in the selection

Invoke-IcingaCheckHyperVSnapshot -Verbosity 2 -CountSnapshotWarning 0 -NoPerfData -ExcludeVms "*-WS41" -AvoidEmptyCheck

[OK] VM Snapshots: 3 Ok
\_ [OK] KOM-WS42
   \_ [OK] KOM-WS42
      \_ [OK] No snapshots created: 0
\_ [OK] KOM-WS43
   \_ [OK] KOM-WS43
      \_ [OK] No snapshots created: 0
\_ [OK] KOM-WS44
   \_ [OK] KOM-WS44
      \_ [OK] No snapshots created: 0

However, if the plugin filters out all virtual machines, we will receive an error

Invoke-IcingaCheckHyperVSnapshot -Verbosity 2 -CountSnapshotWarning 0 -NoPerfData -ExcludeVms "*-WS4*" -AvoidEmptyCheck

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-hyperv\compiled\icinga-powershell-hyperv.ifw_compilation.psm1:785 char:9
+     if ($VirtualComputers.Summary.ContainsKey('SnapshotLocated')) {
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

[OK] VM Snapshots

We need an additional option that allows us to set the status to OK if the VMs are not selected.
Thank you.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions