I am writing a script which checks if a specific sub-folder exists in the list of folders and if so get the list of files older than 2 days from that sub-folder. Below is my folder structure and script. however the Test-path condition always returns false and code inside it doesn't gets executed.
$folder = gci -Path F:\test\
foreach ($f in $folder)
foreach ($i in gci $f.FullName)
# check if the there is a folder called Avengers
if (Test-Path ($i.FullName -contains 'Avengers'))
write-host " Avengers folder exist"
Get-ChildItem -Path $i.FullName -File | Where lastwritetime -lt (Get-Date).AddDays(-2)