1

我正在爲交換2007 LCR和SCR複製的監視腳本工作,以自動執行我的一些日常工作,並確保其他人可以看到是否有問題。我的代碼如下,並且我有一個條件,其中一個數據庫在重播隊列中超過2000個日誌。我知道腳本的恢復工作,因爲如果我檢查沒有.count的輸出,它會返回事務日誌重放隊列過高的數據庫。有人可以向我解釋我做錯了什麼,爲什麼我不能計算輸出?爲什麼.Count方法在EMS/Powershell會話中對此輸出不起作用?

#SCR Replay Queue Length Check 
IF (($SCRstatusTable|? {$_.ReplayQueueLength -ge 2000}).Count -gt 0) 
{ 
    $SCRReplayQueueLengthHealth = "SCR replay queue length check: At least 1 instance 
     is reporting more than 2000 queued logs. Refer to detailed logs for more information." 
} 
ELSE 
    { 
      $SCRReplayQueueLengthHealth = "SCR replay queue length check: No instances 
      currently reporting more than 2000 logs queued for replay." 
     } 

任何幫助,非常感謝!我認爲這是一個語法的事情,因爲我已經使用.count方法計數其他收集輸出沒有問題。

回答

2

試着強迫它進入數組。我已經說明了差異與下面的get-process的cmdlet:

PS > (get-process | select -first 1).count #no count 
PS > @(get-process | select -first 1).count 
1 

所以,你必須做一些事情,如:

@($SCRstatusTable|? {$_.ReplayQueueLength -ge 2000}).Count 
+0

完美的作品。我只是不知道爲什麼。我可以運行一個非常類似的命令,返回相同類型的輸出,並且它可以很好地與.count一起使用。不管它爲什麼起作用,那正是我所需要的。謝謝!!!!! – John

+0

那麼'.Count'是集合的一個屬性。所以如果輸出是一個集合,但它可能不適用於其他任何東西。 – JasonMArcher

相關問題