I'm trying to loop through multiple files to see if a job completed. I'm very new to powershell and am trying to understand the basics of how looping works before creating a more detailed program. I can't figure out what's wrong in my code. When I run the program no output ("Success" or "Fail") is displayed. Any suggestions on looping through sql directory files to search for a specific string appreciated too:)
Get-ChildItem "C:\Users\afila\Desktop\TEST" -Filter "*.txt" |
ForEach-Object{
if(Object.Contains("*Loaded successfully*"))
{
Write-Host "Success"
}
else
{
Write-Host "Fail"
}
}