I'm trying to get a count of files in a directory that are over 30 minutes old. Unfortunately, when I test the script output I just sit and wait on an indefinitely spinning wheel--not even an error or a 0.
When I run the script in PowerShell from the poller it appears to work, so I think the problem is in passing down arguments. I haven't written many scripts for SolarWinds. Can someone tell me what I'm doing wrong here?
Arguments:
-time 30 -ext txt -path \\server\directory\
Script body:
param(
[int]$time,
[string]$ext,
[string]$path)
$count = 0
Foreach ($file in Get-ChildItem $path -Filter *.$ext -recurse)
{
if ($file.LastWriteTime -lt (Get-Date).AddMinutes(-$time))
{
$count = $count + 1
}
}
write-host "statistic:" $count