Monitoring a Windows service with Powershell
Monitor Windows Service with Powershell Description This script is used to monitor a Windows service. If the monitored service is not active, the script will try to restart it. 15 seconds later, it checks its status again, if the service is still stopped, it retrieves the generated logs and sends an alert email. Github link Then simply place the script in a scheduled task and run it regularly. #Function create Log folder Function CreateLogsFolder { If (!( Test-Path C:\Logs)) { New-Item -Force -Path "C:\Logs\" -ItemType Directory } else { Write-Host "Le dossier " C:\Logs\ " existe déjà !" } } #Create Log Folder CreateLogsFolder #Declaration of script variables $Client = "ClientName" $Server = (Get-CimInstance -ClassName Win32_ComputerSystem).Name $Date = Get-Date $ServiceName = "XboxGipSvc" $Log...