需要发送邮件,如果输出结果为真,但我的代码得到邮件真或假
如果是真的,它能提醒我们吗
.............................................
here is the script sending email.
Get-ChildItem D:\Infra\ -Recurse -File | Measure-Object | %{$_.Count} > c:\temp\result.txt
$Output = "D:\Infra\*"
Get-ChildItem D:\Infra\ | select name, lastwritetime, creationTime > c:\temp\file_date_time.txt
Get-date > c:\temp\server_time.txt
((Get-ChildItem $Output | Measure-Object).Count -gt 10)
$attachments = @(
"c:\temp\result.txt"
"c:\temp\file_date_time.txt"
"c:\temp\server_time.txt"
)
$mailArgs = @{
From = ""
To = ""
Subject = ""
Body = ""
Attachments = $attachments
SmtpServer = ""
Port = 25
UseSSL = $true
}
Send-MailMessage @mailArgs
1条答案
按热度按时间zwghvu4y1#
无论对象计数是否大于10,您的脚本都会执行mail部分,因为它缺少求值。