perlestius / Zabbix_Templates

Zabbix Templates
13 stars 8 forks source link

[RFBacklog] not working due to some strange behaviour of Get-WmiObject Asjob for Remote Computer #5

Closed pcamelio closed 1 year ago

pcamelio commented 2 years ago

OS : Windows 2019 Get-WmiObject with ComputerName and -AsJob is not working properly, at least for me.

QuickandDirt solution to overcome the problem Line 259

        $j = Get-WmiObject -ComputerName $RServerName `
                           -Namespace $DFSNamespace `
                           -Query $WMIQuery `
                           -ErrorAction Ignore -AsJob
        [void](Wait-Job $j -Timeout $RequestTimeout)
        If ($j.State -eq "Completed") {
            Try {
                #и пытаемся извлечь с этого партнера вектор версии
                $VersionVector = (Receive-Job $j).GetVersionVector().VersionVector
                #На отправляющем партнере (т.е. на локальном сервере) определяем размер бэклога для найденного вектора
                (Get-WmiObject `
                    -Namespace $DFSNamespace `
                    -Query $WMIQuery).GetOutboundBacklogFileCount($VersionVector).BacklogFileCount
                }
            Catch {
                If ($VersionVector) {
                    "Couldn't retrieve backlog info for vector '$VersionVector'"
                }
                Else {
                    "Version vector not found"
                }
            }
        }
        Else {
            "Couldn't retrieve info from partner '$RServerName'"
        }

by

        try{
        $j = Get-WmiObject -ComputerName $RServerName `
                           -Namespace $DFSNamespace `
                           -Query $WMIQuery `
                           -ErrorAction Ignore 
            Try {
                #и пытаемся извлечь с этого партнера вектор версии
                $VersionVector = $j.GetVersionVector().VersionVector
                #На отправляющем партнере (т.е. на локальном сервере) определяем размер бэклога для найденного вектора
                (Get-WmiObject `
                    -Namespace $DFSNamespace `
                    -Query $WMIQuery).GetOutboundBacklogFileCount($VersionVector).BacklogFileCount
                }
            Catch {
                If ($VersionVector) {
                    "Couldn't retrieve backlog info for vector '$VersionVector'"
                }
                Else {
                    "Version vector not found"
                }
            }
        }
        catch {
            "Couldn't retrieve info from partner '$RServerName'"
        }
perlestius commented 1 year ago

It seems, you have firewall issue. See here for more information.