Trying to montior files in an SMTP queue for age of 15 mins or longer

I am trying to Monitor my SMTP queue on my windows 2012 r2 server

when I use the following script i get an output of 1 in powershell.

$file= Get-ChildItem -Path 'c:\inetpub\mailroot\queue' | ?{$_.LastWriteTime -lt (Get-Date).Addminutes(-15)}
$stats=$file.count
Write-Host "Statistic: $stats"

When i move it over to SAM Powershell Script Monitor I get the following message

Output: ==============================================
Statistic: 0

Errors: ==============================================
Get-ChildItem : Cannot find path 'C:\inetpub\mailroot\queue' because it does not exist.
At line:2 char:8
+ $file= Get-ChildItem -Path 'c:\inetpub\mailroot\queue' | Where-Obj ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\inetpub\mailroot\queue:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 
 
I found out that it is running this powershell script on the Solarwinds server instead of the target server any ideas on how to resolve that?
Parents
  • For this, you can use Windows Performance Monitor counters,

    Counter: Messages in the queue directory
    Instance: _Total
    Category: SMTP NTFS Store Driver

    a quick check via WMI query:

    Get-WmiObject -class Win32_PerfFormattedData_NTFSDRV_SMTPNTFSStoreDriver  | ? { $_.Name -eq '_Total' }
Reply
  • For this, you can use Windows Performance Monitor counters,

    Counter: Messages in the queue directory
    Instance: _Total
    Category: SMTP NTFS Store Driver

    a quick check via WMI query:

    Get-WmiObject -class Win32_PerfFormattedData_NTFSDRV_SMTPNTFSStoreDriver  | ? { $_.Name -eq '_Total' }
Children
No Data