有谁可以告诉我为什么打开而不是发送文件?
$d = [DateTime]::Today.AddDays(-90)
Get-ADComputer -Filter 'lastLogon -le $d' -Properties lastLogon |
Export-Csv c:\temp\stale_servers.csv
If (c:\temp\stale_servers.csv = $?)
{
Send-MailMessage -SmtpServer xxxxxxxxx -To xxxxxxxxx -From xxxxxx -Subject "test mail" -Body "The servers that have not logged in, in the past 90 days are attached." -attachment c:\temp\stale_servers.csv
}
答案 0 :(得分:1)
我认为问题出在这一行:
If (c:\temp\stale_servers.csv = $?)
如果你想测试文件的存在使用:
If (test-path -path "c:\temp\stale_servers.csv" )