# Define parameters $backgroundProcessName = "ZohoWorkDrive.exe" # Replace with actual background process name $EventID = 6005 # System startup event ID $TimeRange = (Get-Date).AddMinutes(-6000) # Check events from the last 60 minutes $DriveLetter = "Z:" # Drive to check $To = "indepthnt@gmail.com" $Outlook = New-Object -ComObject Outlook.Application # Check system reboot $RecentReboot = Get-WinEvent -FilterHashtable @{ LogName = 'System' ID = $EventID StartTime = $TimeRange } -ErrorAction SilentlyContinue # Check if the background process is running $process = Get-Process | Where-Object { $_.ProcessName -eq ($backgroundProcessName -replace ".exe$", "") } # Check if Z drive is accessible $DriveAccessible = Test-Path $DriveLetter # Prepare email body $Body = "" if ($RecentReboot) { $Body += "Your system rebooted at $($RecentReboot.TimeCreated).`n" Write-Output "Your system rebooted at..." } if (-not $process) { $Body += "The background process $backgroundProcessName is not running.`n" Write-Output "$backgroundProcessName is not running..." } if (-not $DriveAccessible) { $Body += "The drive $DriveLetter is not mapped or accessible.`n" Write-Output "$DriveLetter is not mapped or accessible..." } # Send email if any condition is met if ($Body -ne "") { $Mail = $Outlook.CreateItem(0) $Mail.To = $To $Mail.Subject = "Zoho Sync Connectivity Event Notification" $Mail.Body = $Body $Mail.Send() Write-Output "Email Notification is sent.." } else { Write-Output "Everything looks good!" }