为什么 .Count 方法不能在 EMS/Powershell 会话中针对此输出工作?

发布于 2024-12-29 02:11:50 字数 756 浏览 2 评论 0原文

我正在开发一个用于 Exchange 2007 LCR 和 SCR 复制的监视脚本,以自动化我的一些日常工作,并确保其他人可以看到是否出现问题。我的代码如下,我遇到的情况是其中一个数据库的重播队列中的日志数超过 2000 个。我知道脚本的恢复有效,因为如果我检查没有 .count 的输出,它确实返回事务日志重播队列太高的数据库。有人可以向我解释我做错了什么以及为什么我无法计算输出吗?

#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 方法来计算其他集合输出,没有出现问题。

I am working on a monitoring script for exchange 2007 LCR and SCR replication to automate some of my daily work and make sure other people can see if something is wrong. My code is below and I have a condition where one of the databases is above 2000 logs in the replay queue. I know the resto of the script works because if I check the output without the .count, it does return the database whose transaction log replay queue is too high. Can someone explain to me what I am doing wrong and why I can't count the output?

#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."
         }

Any help is greatly appreciated! I am thinking it is a syntax thing as I have used the .count method to count other collection output without a problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光与爱终年不遇 2025-01-05 02:11:50

尝试将其强制放入数组中。我已经在下面说明了 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

Try forcing it into an array. I have illustrated the difference with the get-process cmdlet below:

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

So you have to do something like:

@($SCRstatusTable|? {$_.ReplayQueueLength -ge 2000}).Count
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文