Send email alert if Reboot or shutdown a Server with Powershell
Présentation This script allows to send a status mail when a server restarts or stops. All actions are logged to C:\Logs. Github Link : https://github.com/ChrisMogis/Scripts/blob/main/Alert_State_Server.ps1 Exécution command line for reboot status : powershell.exe -executionpolicy ByPass -file .\ScriptName.ps1 -Option Reboot Exécution command line for shutdown status : powershell.exe -executionpolicy ByPass -file .\ScriptName.ps1 -Option Shutdown #Script Parameters Param ( [Parameter(Mandatory= $true )] [ValidateSet( "Reboot" , "Shutdown" )] [String[]] $Option ) #Function create Log folder Function CreateLogsFolder { If (!( Test-Path C:\Logs)) { New-Item -Force -Path "C:\Logs\" -ItemType Directory } else { Write-Host "The folder " C:\Logs\ " already exists !" } } #Create Log Folder CreateLogsFolder #Declaration of script variables ...