Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $A = get-service vss
- if ($A.Status -eq "Stopped") {$A.start()} elseIf ($A.status -eq "Running") {Write-Host -ForegroundColor Yellow $A.name "is running"}
- ping 1.1.1.1 -n 6 # wait for 6 seconds
- $A = get-service w32time
- if ($A.Status -eq "Stopped") {$A.start()} elseIf ($A.status -eq "Running") {Write-Host -ForegroundColor Yellow $A.name "is running"}
- $services = Get-Service "VSS, W32time"
- foreach($service in $services){$service.Name}
- if ($Service.Status -ne "Running") {
- $Body = "$($service.DisplayName) is not running"
- } else {
- $Body = "$($service.Displayname) is running "
- }
- $From = "email"
- $To = "emails"
- $SMTPServer = "smtp"
- $SMTPPort = "587"
- $Username = "email"
- $Password = "password"
- $Body =$body
- $Subject = "$computer$ status"
- $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
- $smtp.EnableSSL = $false
- $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
- $smtp.Send($From, $To, $subject, $body);
- $computer = $env:computername
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement