With help from C.B. this is my new search which eliminates the issues I was having.
- Changed
-Path
toC:\ProgramData\flx\Output\*\*\*\*
to help limit the depth that was searched. - Used
-Filter
instead of-Include
and put the-Exclude
logic into the where clause.
Get-ChildItem -Path C:\ProgramData\flx\Output\*\*\*\* -Filter "*.msi" | where {$_.Name -notlike "*.Context.msi" -and $_.LastAccessTime -gt (Get-Date).AddMinutes(-15)}