Server up time
Get-ExchangeServer | where{$_.name -like‘wendy*‘} | %{ if(Test-Connection $_.name -Count 1 -Quiet) { $OS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $_.name $uptime = (Get-Date) - $OS.ConvertToDateTime($OS.LastBootUpTime) $report= "$($_.name) has been up for {0} days, {1} hours and {2} minutes." ` -f $uptime.Days, $uptime.Hours, $uptime.Minutes + "`r" } } $msg=$msg+$report Send-MailMessage -To xxxx -From xxxx ` -Subject "Server Uptime" -Body $msg -SmtpServer xxxxx
时间: 2024-12-16 11:13:11