Hi All,
I was given some help from you guys to get a wmi reboot check working which it now does fine but when i run it as a task I do not get the email.
This is what I run on a w2008r2 box
$a = gc c:\Servers.txt | %{
$lastBoot = Get-WmiObject Win32_OperatingSystem -computer $_ | %{[System.Management.ManagementDateTimeCOnverter]::ToDateTime($_.LastBootUpTime)}
$obj = New-Object –TypeName PSObject –Prop(@{'LastBoot'=$lastBoot;'Name'=$_;})
$obj
}
Send-MailMessage -From "a.user@abc.com" -To "b.user@abc.com" -Subject "XA Reboot Check" -Body ($a | out-string) -smtp smtpserver
And for the scheduled task I run it at the highest privilege and tell it to start a program Powershell -File C:\Temp\Scripts\RebootCheck.ps1
Any idea on what I am doing wrong would be great