A Streamlit application that converts plain-English Active Directory (AD) requests into PowerShell Get-AD* commands using the OpenAI API, with validation, logging, and a local fallback mode.
- Translate natural language into PowerShell AD query commands
- Restrict generated output to read-only
Get-AD*style commands - Block potentially unsafe modification command patterns (
Remove-,Set-,Add-) - Streamlit UI with:
- built-in example prompts
- syntax-highlighted PowerShell output
- query history and favorites
- Environment-driven configuration via
.env - Logging for app activity and translation errors
.
├── main.py # Streamlit UI
├── translator.py # Prompting, model call, and command validation
├── config.py # Environment/config loading
├── requirements.txt # Python dependencies
└── README.md
- Python 3.9+
- Access to OpenAI API (unless using local fallback mode)
Install dependencies:
pip install -r requirements.txtCreate a .env file in the project root:
OPENAI_API_KEY=your_openai_api_key_here
USE_LOCAL_MODEL=FalseOPENAI_API_KEY: Required whenUSE_LOCAL_MODEL=FalseUSE_LOCAL_MODEL:TrueorFalse(default:False)
Note: Local fallback is currently a stub and does not perform real translation.
streamlit run main.pyThen open the local URL shown by Streamlit (typically http://localhost:8501).
- Find users who haven't logged in for 90 days
- Show all admin groups
- List service accounts
- Check if a user is a member of a group
- Find computers in the HR department
- Identify disabled accounts
- The app builds a prompt from your natural language query.
- The OpenAI Completion API generates a PowerShell command.
- The output is validated to ensure it is AD query-oriented and non-destructive.
- The resulting command is displayed with syntax highlighting.
app.log: Streamlit application eventsquery.log: Translation requests and errors
This project is licensed under the MIT License.