-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetServiceStatus.ps1
More file actions
23 lines (15 loc) · 873 Bytes
/
Copy pathGetServiceStatus.ps1
File metadata and controls
23 lines (15 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
############ Service names ###############
$services = @('Spooler','TeamViewer')
########### email credentials ############
$emailPass = 'password'
$emailName = 'test'
########## email settings ################
$emailSrcAdress = 'test@gmail.com'
$emailDstAddress = 'test@outlook.com'
$smtpServer = "smtp.gmail.com"
$smtpPort = 587
##########################################
$secpasswd = ConvertTo-SecureString $emailPass -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($emailName, $secpasswd)
######## Send_message ######################
Send-MailMessage -From $emailSrcAdress -To $emailDstAddress -Subject "Service status on $env:computername $(Get-Date -Format g)" -Body ($services | ForEach-Object {Get-Service -Name $_} | Format-Table -Wrap | Out-String) -SmtpServer $smtpServer -Port $smtpPort -credential $mycreds -UseSsl