What you will learn in this TP
- Write to an event log
- Schedule a PowerShell script
- Filter logs and configure service recovery
Introduction #
What you will learn in this section
- Write to an event log
- Schedule a PowerShell script
- Filter logs and configure service recovery
Context. A server’s print service stops regularly and the disk fills up without warning. Before installing a monitoring tool, you set up native monitoring.
Prerequisites: a disposable Windows Server 2025 virtual machine (free evaluation) with an administrator account, and PowerShell open as administrator · Estimated duration: 45 min
A scheduled task that writes events, Get-WinEvent queries and a service that restarts by itself.Setup #
Guided steps, with their solution.
1. Create an event source
Why? A script that writes to Windows logs is visible to every monitoring tool.
Create theControleServeursource in the Application log and write a test event (ID 1000).2. Write the check script
Why? A simple, reliable check beats a badly configured tool.
WriteC:\TP\Scripts\Controle.ps1: warning (ID 2001) if a volume has less than 15% free, error (ID 2002) for each stopped automatic service, otherwise an event 1000.3. Schedule the check
Why? Task Scheduler runs the script without a logged-on session, as SYSTEM.
Create the task\Exploitation\Controle serveurevery 15 minutes, start it and check its result.4. Cause and detect an incident
Why? You check that an alert actually fires.
Stop theSpoolerservice, run the task again, then find event 2002 and the service stop in the System log (ID 7036).5. Automatic recovery
Why? The service control manager can restart a failed service without intervention.
Configure Spooler to restart after 1 minute on the first two failures, then simulate a crash by killing its process.6. Analyze the logs
Why? A few queries answer the most common incident questions.
Display System errors of the last 24 hours grouped by source, the latest restarts (1074, 6008) and failed logons (4625) of the last hour.
Difficulty level : ●●○○○ (2/5)
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Services, scheduled tasks, event logs and performance
Control Windows services and their recovery, automate with Task Scheduler, use event logs with Ge...
Packages, systemd services, logs and scheduled tasks
Install and update software with apt and dnf, manage services with systemctl, write a systemd uni...
PowerShell for Windows administrators
Master PowerShell to administer Windows: cmdlets and help, object pipeline, filters and formats, ...
Active Directory Domain Services and DNS
Understand and deploy Active Directory: forest, domains, organizational units, domain controllers...
Windows and Windows Server: versions, editions and architecture
Discover the Windows ecosystem for administrators: Windows 11 and Windows Server 2025, editions a...
Monitoring and protecting Azure: Monitor, Log Analytics, Defender, Key Vault and Backup
Operate Azure: Azure Monitor (metrics, activity logs, alerts), Log Analytics and KQL, Application...
Windows networking: IP, DNS, DHCP, firewall and remote access
Configure and troubleshoot Windows networking with PowerShell, deploy a DHCP server, master Windo...
Users, groups, NTFS permissions and SMB shares
Manage local accounts and groups, understand UAC, apply NTFS permissions with inheritance, create...
Group Policy (GPO): configuring the estate from Active Directory
Design and troubleshoot Group Policy: computer and user configuration, OU linking, LSDOU order, i...