Start-AIEventAnalyzer.ps1 is a PowerShell script for analyzing Windows Event Logs with help from Azure OpenAI through the PSAOAI module.
It is intended for administrators, support engineers, and IT professionals who need a faster way to review recent Windows event data, generate troubleshooting ideas, and summarize noisy logs into actionable next steps. It is most useful when manual log review is too slow, repetitive, or hard to interpret at scale.
It lets you:
- choose an analysis action such as Analyze, Troubleshoot, Correlate, or Summarize,
- select a Windows event log and severity level,
- send recent event data to Azure OpenAI,
- review AI-generated follow-up prompts and responses,
- save results to log files for later reference.
- Windows PowerShell / PowerShell with access to Windows Event Logs
- Windows operating system (the main functionality depends on
Get-WinEventand Windows event log access) - Internet connectivity to Azure OpenAI
- Azure OpenAI access configured for the
PSAOAImodule - Installed PowerShell module:
PSAOAI
Note This project is intended for Windows environments. It is not expected to work functionally on Linux, macOS, or WSL because those environments do not provide native access to Windows Event Logs in the same way.
Install the required module:
Install-Module PSAOAI -ForceInstall the script from PowerShell Gallery:
Install-Script Start-AIEventAnalyzer -ForceUpdate the script later with:
Update-Script Start-AIEventAnalyzer -ForceBefore running the script, configure the environment variables required by PSAOAI:
API_AZURE_OPENAI_KEY- Azure OpenAI API keyAPI_AZURE_OPENAI_ENDPOINT- Azure OpenAI endpoint, for example:https://<RESOURCE_NAME>.openai.azure.comAPI_AZURE_OPENAI_DEPLOYMENT- deployment name used by the modelAPI_AZURE_OPENAI_APIVERSION- Azure OpenAI API version
Example:
$env:API_AZURE_OPENAI_KEY = "<your-key>"
$env:API_AZURE_OPENAI_ENDPOINT = "https://<resource>.openai.azure.com"
$env:API_AZURE_OPENAI_DEPLOYMENT = "gpt-4"
$env:API_AZURE_OPENAI_APIVERSION = "2024-02-01"Data handling note The function sends selected Windows event data to Azure OpenAI for analysis. Before using it in production, review whether the chosen event log entries may contain sensitive, personal, or security-relevant information.
Minimal happy-path:
Install-Module PSAOAI -Force
Install-Script Start-AIEventAnalyzer -Force
Start-AIEventAnalyzerIf the script is installed but PowerShell cannot find it by name, it is often because Install-Script places scripts in a folder that is not automatically added to PATH.
If the script is installed and available in your PowerShell path:
Start-AIEventAnalyzerIf PowerShell cannot find the script by name, check where it was installed:
Get-InstalledScript Start-AIEventAnalyzer | Select-Object InstalledLocationThen either:
- run it using the full path, or
- add the install folder to your
$env:PATH
Example:
& "<InstalledLocationFolder>\Start-AIEventAnalyzer.ps1"From the project folder:
. .\Start-AIEventAnalyzer.ps1
Start-AIEventAnalyzerThe script supports two usage modes.
Run the function without parameters:
Start-AIEventAnalyzerIn interactive mode, the function prompts you to choose:
- analysis action,
- event log name,
- severity level,
- number of recent events to analyze.
You can also call the function with parameters:
. .\Start-AIEventAnalyzer.ps1
Start-AIEventAnalyzer -LogName "Microsoft-Windows-AAD/Operational" -Serverity All -Action Optimize -Events 50Important The current function uses the parameter name
-Serverity. This spelling is preserved here intentionally to match the actual implementation.
| Parameter | Required | Description |
|---|---|---|
LogName |
No | Windows event log name to analyze. If omitted, the script prompts you to choose one. |
Serverity |
No | Severity level filter. Supported values: Critical, Error, Warning, Information, Verbose, All. |
Action |
No | Analysis action. Supported values: Analyze, Troubleshoot, Correlate, Predict, Optimize, Audit, Automate, Educate, Documentation, Summarize. |
Events |
No | Number of most recent events to analyze. |
LogFolder |
No | Output folder for saved log files. If omitted, the script uses AIEventAnalyzer under the user's Documents folder. |
At a high level, the workflow is:
- Show a banner and check for newer script versions.
- Load the
PSAOAImodule. - Let the user choose an analysis action or accept parameters.
- Read Windows event log entries with the selected filters.
- Generate AI prompts tailored to the selected action.
- Run AI analysis on the selected event data.
- Save session data and responses to log files.
- Optionally summarize the session before exit.
The script supports these actions:
AnalyzeTroubleshootCorrelatePredictOptimizeAuditAutomateEducateDocumentationSummarize
These actions influence the system prompt sent to Azure OpenAI and determine the style of generated follow-up prompts.
By default, output is stored in:
%USERPROFILE%\Documents\AIEventAnalyzer
or, from PowerShell:
[Environment]::GetFolderPath("MyDocuments")The script writes plain-text log files. In practice, each run creates timestamped files whose names are based on the selected action, event log, severity level, and time of execution.
The generated files capture:
- selected action, event log, severity, and event count,
- prompt content,
- AI responses,
- session-related information.
Note The exact filename shape comes from the current script implementation. Event log names may contain characters that are relevant to file naming, so this behavior should be treated as implementation-dependent.
If you want to use a custom output location:
Start-AIEventAnalyzer -LogFolder "C:\Logs\AIEventAnalyzer". .\Start-AIEventAnalyzer.ps1
Start-AIEventAnalyzer. .\Start-AIEventAnalyzer.ps1
Start-AIEventAnalyzer -LogName "Microsoft-Windows-AAD/Operational" -Serverity All -Action Optimize -Events 50Use this when you want the AI to focus on recent Error events from the System log and propose likely causes or next diagnostic steps.
. .\Start-AIEventAnalyzer.ps1
Start-AIEventAnalyzer -LogName "System" -Serverity Error -Action Troubleshoot -Events 25. .\Start-AIEventAnalyzer.ps1
Start-AIEventAnalyzer -LogName "System" -Serverity Error -Action Troubleshoot -Events 25 -LogFolder "C:\Temp\AIEventAnalyzer"- The script is designed primarily for interactive use.
- It depends on the external
PSAOAImodule and Azure OpenAI availability. - Output quality depends on the selected model, prompt quality, and the event data provided.
- Large logs or expensive queries may take time.
- Because the project focuses on Windows Event Logs, non-Windows environments are out of scope.
Check the install location:
Get-InstalledScript Start-AIEventAnalyzer | Select-Object InstalledLocationThen run the script by full path or add the install folder to $env:PATH.
Install it with:
Install-Module PSAOAI -ForceVerify the values:
Get-ChildItem Env:API_AZURE_OPENAI*Check:
- whether the selected event log contains matching events,
- whether Azure OpenAI credentials and deployment are valid,
- whether the
PSAOAImodule works independently.
A few details are worth keeping explicit in documentation:
- the function name is
Start-AIEventAnalyzer, - the current parameter name is
Serverity(notSeverity), - the script is both installable from PowerShell Gallery and runnable from source,
- the main behavior is interactive, even though parameters are also supported.
- GitHub: https://github.com/voytas75/AIEventAnalyzer
- PowerShell Gallery script: https://www.powershellgallery.com/packages/Start-AIEventAnalyzer
- PowerShell Gallery module: https://www.powershellgallery.com/packages/PSAOAI/