This module provides comprehensive system monitoring and performance tracking capabilities for Windows systems.
- PowerShell 5.1 or later
- Windows 10/Server 2016 or later
- Administrative privileges for some functions
- Common module (automatically imported as a dependency)
Retrieves and filters system event logs with customizable time ranges and event types.
# Get system events from the last 12 hours
Get-SystemEventLogs -Hours 12
# Get specific event types
Get-SystemEventLogs -EventType Error,Warning -Hours 24Monitors system memory usage and provides detailed statistics.
# Get current memory usage
Get-MemoryUsage
# Get memory usage with threshold alert
Get-MemoryUsage -Threshold 90Monitors CPU usage and provides process-level statistics.
# Get current CPU usage
Get-CPUUsage
# Get top CPU consuming processes
Get-CPUUsage -Top 10Identifies processes consuming excessive memory.
# Get processes using more than 5% memory
Get-HighMemoryProcesses -Threshold 5
# Get top memory consuming processes
Get-HighMemoryProcesses -Top 10Monitors system services status and health.
# Get all services
Get-SystemServices
# Get services with specific status
Get-SystemServices -Status RunningProvides comprehensive system performance metrics.
# Get all performance metrics
Get-SystemPerformance
# Get specific performance counters
Get-SystemPerformance -Counters 'Memory', 'CPU', 'Disk'Import the module in your scripts:
Import-Module .\SystemMonitoring# Check system health
$health = @{
Memory = Get-MemoryUsage
CPU = Get-CPUUsage
Services = Get-SystemServices -Status Running
Events = Get-SystemEventLogs -Hours 1 -EventType Error,Warning
}
# Export to CSV
$health | Export-Csv -Path "SystemHealth_$(Get-Date -Format 'yyyyMMdd_HHmmss').csv"# Monitor system performance every 5 minutes
while ($true) {
$performance = Get-SystemPerformance
Write-LogMessage -Message "Performance metrics collected" -Level Info
Start-Sleep -Seconds 300
}All functions include:
- Proper error handling and logging
- Input validation
- Detailed error messages
- Logging through the Common module
When adding new monitoring functions:
- Add the function to SystemMonitoring.psm1
- Update the FunctionsToExport list in SystemMonitoring.psd1
- Update this README with function documentation
- Include appropriate error handling and logging
- Add parameter validation
- Include examples in the function comment-based help