OTel Agent Testing
Windows
Windows Security Logs
# First, ensure your event source is registered (run as administrator) New-EventLog -LogName "Security" -Source "MySecurityTest" # Loop to write multiple security events for ($i = 1; $i -le 10; $i++) { Write-EventLog -LogName "Security" -Source "MySecurityTest" -EventId 5001 -EntryType FailureAudit -Message "Test security event number $i" Start-Sleep -Seconds 1 # Optional: Add a delay between events }# This script will attempt to log on with invalid credentials, generating failed logon events. # Replace 'InvalidUser' and 'InvalidPassword' with actual invalid credentials. # Replace 'TargetComputer' with the name of the computer where the event should be generated. $username = "InvalidUser" $password = "InvalidPassword" # Or use $env:COMPUTERNAME for the local machine $targetComputer = "TargetComputer" # Loop to generate multiple failed logon attempts for ($i = 0; $i -lt 10; $i++) { # Generates 10 failed logon attempts try { # Attempt a network logon with invalid credentials # This will typically generate Event ID 4625 (An account failed to log on) $null = New-Object System.Net.NetworkCredential($username, $password) $null = [System.Security.Principal.WindowsIdentity]::Impersonate($null) } catch { # Catching the error to prevent script termination, as the logon is expected to fail. Write-Host "Attempt $i failed as expected." } Start-Sleep -Seconds 1 # Pause to avoid overwhelming the system or event log }# This command will intentionally fail to authenticate, generating a failed logon event New-PSSession -ComputerName localhost -Credential (Get-Credential) -Authentication Negotiate# Create a dummy file New-Item -Path C:\Temp\TestFile.txt -ItemType File -Value "This is a test." # Attempt to read the file (after enabling object access auditing on C:\Temp) Get-Content C:\Temp\TestFile.txt# This command modifies a local security setting, potentially triggering a log Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "FullPrivilegeAuditing" -Value 1# This command will be logged if Script Block Logging is enabled Get-Process | Where-Object {$_.CPU -gt 10}# This command creates a new scheduled task, which can generate a security event Register-ScheduledTask -TaskName "MyTestTask" -Action (New-ScheduledTaskAction -Execute "notepad.exe") -Trigger (New-ScheduledTaskTrigger -Once -At "3:00 PM")New-LocalUser -Name "TestUser" -Description "User for testing" -NoPassword
Windows Systems Logs
Windows Application Logs
Check Windows Time Zone
Linux
Using logger command
Manual log entries
Security Logs
System Logs
Automated Log Generation
Log Rotation Testing
macOS
Resources
Last updated
Was this helpful?

