简体   繁体   English

Powershell脚本只返回来自和Exchange 2003邮箱的totalitems

[英]Powershell script to return only totalitems from and exchange 2003 mailbox

I'm working on a Powershell script that will return only the total items from and Exchange 2003 mailbox. 我正在开发一个Powershell脚本,该脚本只返回来自Exchange 2003邮箱的总项目。 So far I have this: 到目前为止我有这个:

get-wmiobject -computername exchange01 -namespace root\\microsoftexchangev2 -class exchange_mailbox -filter "mailboxdisplayname='Journal Mail'" | get-wmiobject -computername exchange01 -namespace root \\ microsoftexchangev2 -class exchange_mailbox -filter“mailboxdisplayname ='Journal Mail'”| select-object totalitems | select-object totalitems | write-host 写主机

However this give the results as: 然而,结果如下:

@{totalitems=939} @ {TOTALITEMS = 939}

I only want the number to be returned as we have an external program that will read this number and send a notification if it exceeds a predetermined number. 我只想要返回号码,因为我们有一个外部程序会读取这个号码并在超过预定数量时发送通知。

I'm having trouble finding a way to strip out all the unnecessary information from the results. 我找不到从结果中删除所有不必要信息的方法。 Any suggestions are welcome to how I can accomplish this. 欢迎任何建议我如何实现这一目标。

Select-Object returns an object with one property, assign the result to a variable and refer to the property name: Select-Object返回具有一个属性的对象,将结果分配给变量并引用属性名称:

$mbx = get-wmiobject -computername exchange01 -namespace root\microsoftexchangev2 -class exchange_mailbox -filter "mailboxdisplayname='Journal Mail'" 
$mbx.totalitems

尝试这是否有效:

get-wmiobject -computername exchange01 -namespace root\microsoftexchangev2 -class exchange_mailbox -filter "mailboxdisplayname='Journal Mail'" | select-object -ExpandProperty totalitems 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM