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
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