I would like to restart the server using powershell and also want to know whether or not the reboot was successful.
I have created the powershell script:
Restart-Computer -ComputerName Qyhz –Force -ErrorVariable status
if ($status.fullyqualifiederrorid -like "*Failed*")
{
Write-Log -Message 'server restart failed.' -Path c:\temp\test.log
}
else
{
Write-Log -Message 'server restart succeeded.' -Path c:\temp\test.log
}
send -mailmessage -from operating.system@abc.com -To asdf@abc.com -subject test -attachment 'c:\Temp|test.log' -smtp server "127.0.0.1"
Can any one suggest me how to send a status email?