I have my code here:
<code>Function Send-Warnings {
$filesList = @("incorrectfile1.txt", "incorrectfile2.txt", "correct-file.txt")
foreach ($pattern in $filesList) {
if ($file = Get-ChildItem -Path $LOCAL_LOCATION -Filter $pattern -ErrorAction SilentlyContinue){
} else {
Log-Message "$($pattern): does not exist in $LOCAL_LOCATION"
CompleteTask $script:Warning
}
}
}
</code>
<code>Function Send-Warnings {
$filesList = @("incorrectfile1.txt", "incorrectfile2.txt", "correct-file.txt")
foreach ($pattern in $filesList) {
if ($file = Get-ChildItem -Path $LOCAL_LOCATION -Filter $pattern -ErrorAction SilentlyContinue){
} else {
Log-Message "$($pattern): does not exist in $LOCAL_LOCATION"
CompleteTask $script:Warning
}
}
}
</code>
Function Send-Warnings {
$filesList = @("incorrectfile1.txt", "incorrectfile2.txt", "correct-file.txt")
foreach ($pattern in $filesList) {
if ($file = Get-ChildItem -Path $LOCAL_LOCATION -Filter $pattern -ErrorAction SilentlyContinue){
} else {
Log-Message "$($pattern): does not exist in $LOCAL_LOCATION"
CompleteTask $script:Warning
}
}
}
It only prints out the first incorrectfile1.txt
after the code is ran in the log message. It doesn’t print out both incorrectfile1.txt
and incorrectfile2.txt
in the log message. Am I not iterating through each element in my list?
Also how do I add another log-message stating Log-Message "##Warning FILES: [END]"
at the bottom? I tried adding it after each }
and the log message doesn’t print out in the terminal.