Skip to content

expphoto/ai-auto-azure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

AI‑Auto (Azure) — Windows Troubleshooting Agent

This README covers the Azure OpenAI version of the AI‑Auto Troubleshooter.

Files:

  • aiauto_azure.ps1 — PowerShell script that talks to Azure OpenAI Chat Completions
  • aiauto_azure.bat — Windows launcher that prompts for inputs and runs the PS1

Prerequisites

  • Windows 10/11 with PowerShell 5+
  • Internet access to your Azure OpenAI resource
  • Azure OpenAI resource with a deployed Chat model (e.g., gpt-4o-mini or similar)
  • One Azure OpenAI API key

Required Environment Variables

Set these once (Machine or User scope). The script reads Machine → User → Process.

  • AZURE_OPENAI_ENDPOINThttps://<your-resource>.openai.azure.com
  • AZURE_OPENAI_DEPLOYMENT — The deployment name you created (not the base model name)
  • AZURE_OPENAI_API_KEY — Your Azure OpenAI key
  • AZURE_OPENAI_API_VERSION — Optional. Defaults to 2024-08-01-preview

Set via Command Prompt (Machine scope)

REM Run an elevated Command Prompt
setx AZURE_OPENAI_ENDPOINT "https://your-resource.openai.azure.com" /M
setx AZURE_OPENAI_DEPLOYMENT "your-deployment" /M
setx AZURE_OPENAI_API_KEY "<your-key>" /M
setx AZURE_OPENAI_API_VERSION "2024-08-01-preview" /M

REM For the current window (without restarting):
set AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
set AZURE_OPENAI_DEPLOYMENT=your-deployment
set AZURE_OPENAI_API_KEY=<your-key>
set AZURE_OPENAI_API_VERSION=2024-08-01-preview

Set via PowerShell (Current session)

$env:AZURE_OPENAI_ENDPOINT    = 'https://your-resource.openai.azure.com'
$env:AZURE_OPENAI_DEPLOYMENT  = 'your-deployment'
$env:AZURE_OPENAI_API_KEY     = '<your-key>'
$env:AZURE_OPENAI_API_VERSION = '2024-08-01-preview'  # optional

How To Run

Option A: Double‑click the BAT launcher

  1. Double‑click aiauto_azure.bat
  2. Enter the troubleshooting goal (e.g., "Investigate slowness")
  3. Adjust options (Max steps, per‑command timeout, flags)
  4. Script runs and then opens the report in Notepad

Option B: Run PowerShell directly

powershell -ExecutionPolicy Bypass -File .\aiauto_azure.ps1 \
  -Goal "Investigate slowness" \
  -MaxSteps 5 \
  -CmdTimeoutSec 45 \
  -AllowMaintenance \
  -AllowKill

All parameters are optional except -Goal. If omitted, defaults are used.


Flags & Behavior

  • -AllowMaintenance: Enables safe maintenance (SFC/DISM, service restarts)
  • -AllowKill: Allows targeted process kills by PID (taskkill /PID <n>, Stop-Process -Id <n>)
  • -AllowDangerous: Operator override. Still blocks hard‑denied commands
  • -MaxSteps: Max AI planning loop iterations (default 5)
  • -CmdTimeoutSec: Per‑command timeout (default 45s)
  • -ReportPath: Where the final Markdown report is saved (defaults to Desktop if not set)

Guardrails:

  • Hard‑denies destructive operations (format, shutdown, bcdedit, etc.)
  • Allows read‑only diagnostics by default
  • Maintenance and kills require explicit flags

What The Script Does

  1. Prompts the Azure model to propose 1–2 safe diagnostic commands per step (JSON only)
  2. Executes commands through a policy gate and captures short output previews
  3. Iterates for up to MaxSteps
  4. Generates a concise Markdown report with findings and next steps

Logs are written to: C:\ProgramData\AIExec\logs\run_*.log


Troubleshooting

  • Error about environment variables: Ensure all required AZURE_OPENAI_* values are set
  • 401/403 from API: Check the key and that your deployment name is correct
  • Empty or malformed model output: The script retries the loop only when JSON parses; otherwise it stops and still writes a report
  • No report opened: The BAT writes to a temp file path and then opens it; confirm the file exists and Notepad is available

Notes

  • Azure endpoint format used by the script:

    https://{endpoint}/openai/deployments/{deployment}/chat/completions?api-version={version}

  • Auth header: api-key: <your-key>

  • Request body uses only messages (deployment is selected by URL)


Example

REM Launch the Azure version
aiauto_azure.bat

REM Or call PowerShell directly
powershell -NoProfile -ExecutionPolicy Bypass -File .\aiauto_azure.ps1 -Goal "Network drops when docking" -MaxSteps 6 -CmdTimeoutSec 60

Security Considerations

  • Read‑only actions by default; maintenance and kills are opt‑in
  • Hard‑denies persist even with -AllowDangerous
  • All executed commands and brief outputs are logged to the run log

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors