Good day,
I am struggling to find a way to add an exclusion list to my foreach email script.
I have tried the following:
$csv = Import-Csv "C:\Stuff\Scripts\data.csv"
$csvexcl = Import-csv 'C:\Stuff\Scripts\Exclusions.csv'
foreach ($row in $csv) {
if($($row.Network) -ne $csvexcl.Network)
{
if ($row.'WAN1 Status' -eq 'Ready')
{
Send-MailMessage -To $recipient -From $sender -Subject "$($row.Network) WAN1 is Ready!"
-SmtpServer $smtpserver
}
}
}
Each time I try modify the code I seem to be getting farther away from the desired result. It still keeps sending emails including the networks I am trying to exclude.
Please could someone be so kind to point me in the right direction?
Thank you
Aucun commentaire:
Enregistrer un commentaire