Загрузка...

PowerShell Send email if windows service is not running

In This Video we are going to see how to send email if service is not running. Here we are only checking if service is in stopped state and sending email to respective ID. If you want to start the service, you can put the command in the If statement. Please use the script and let me know if you have any query.

======================= Script Here ======================
$ServiceName = 'AdobeARMservice'
$arrService = Get-Service -Name $ServiceName

if ($arrService.Status -ne 'Running')
{
Send-MailMessage -From 'administrator@sitech.com' -To 'Swapnil swapnil@sitech.com' -Subject 'AdobeARMservice : Service Not running' -SmtpServer 'mum-srv01.sitech.com'
(Get-Date).toString("yyyy/MM/dd HH:mm:ss") | Out-File -FilePath C:\Scripts\TestLog.txt –Append
Get-Service -Name $ServiceName | Out-File -FilePath C:\Scripts\TestLog.txt –Append
}
else
{
(Get-Date).toString("yyyy/MM/dd HH:mm:ss") | Out-File -FilePath C:\Scripts\TestLog.txt –Append
Get-Service -Name $ServiceName | Out-File -FilePath C:\Scripts\TestLog.txt –Append
}
======================================
Get Local Group Members from Remote computers
https://youtu.be/oWRy_OlyXGg

PowerShell Script To Change Service Account or Update Password
https://youtu.be/lo5hL_I7k-4

PowerShell How To Change Remote Computer (Workgroup) Local Account Password
https://youtu.be/-HiqbiR9lnM

Delete Virtual Machine Snapshots Older Than Specific Days
https://youtu.be/PeUJvlGvGyM

How To Create File Selection Dialog Box in PowerShell
https://youtu.be/5ZEKxSSmQ1w

Add User/Group To The Local Administrators/RDP Group On Multiple Computers
https://youtu.be/rrRMSSL913Q

Get Windows Updates list from Remote Computer
https://youtu.be/A6kPDH_9pO4

PowerShell Remotely Uninstall Software from Multiple Computers
https://youtu.be/978myp7AD5s

PowerShell Search Specific KB Status on Remote Computers
https://youtu.be/9HtcVT_kifg

PowerShell Script to Connect Multiple Server's Remote Session
https://youtu.be/zaSxFqLTf0s

PowerCLI Script to power ON dedicated VMs listed in a text file
https://youtu.be/4DWVuFaSxYA

PowerCLI Script to power Off dedicated VMs listed in a text file
https://youtu.be/bcz_5QUEhR8

Delete Snapshot's from Multiple Virtual Machines
https://youtu.be/yfQ50dyEjSU

Create Snapshot on Multiple Virtual Machine
https://youtu.be/Nsmsa9FgFv4

How can I check if a port is open remotely
https://youtu.be/-JCKk9_vVBc

Installing software remotely on Multiple "Workgroup" Computers
https://youtu.be/QT4u74JWbOM

PowerShell Installing software remotely on Multiple Computers
https://youtu.be/E9yaYVbzgb4

Unable to move OU in Active Directory (Access is denied)
https://youtu.be/0XRizUBbj3s

PowerShell Installing software remotely on Multiple Computers
https://youtu.be/E9yaYVbzgb4

Get Multiple Services Status Remotely | Remotely Start or Stop Services
https://youtu.be/C8PrFNbdLj8

Get Date and Time from Multiple Remote Computers
https://youtu.be/ZpMio_y1zn8

PowerCLI - How to get HA restarted VM's List
https://youtu.be/0IRJvZH9paQ

Get-Childitem - Search file on Local and Remote Computers
https://youtu.be/kHkD5M-mk0A

Remotely Create Update Delete Registry Key on Multiple Computers
https://youtu.be/Hxlqr3zdxHM

Get service status from remote server's using PowerShell
https://youtu.be/7fIG_brMONU

Видео PowerShell Send email if windows service is not running канала Swapnil Infotech
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки

На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.

Об использовании CookiesПринять