Home / use case

A PowerShell 7 profile that talks to a local Ollama model, with a human gate on every command

At a glance
Models & engines
Ollama on 127.0.0.1:11434
qwen2.5:7b as the default model in the sample and in ops-settings.json
nomic-embed-text for the mem command
Key gotcha
The news command fetches feeds from the network, then summarizes them locally. The author treats that fetched content as data, not as instructions.

What they built

The author already works in the terminal and did not want to paste process lists, file paths or secrets into a browser chat. They added an LLM to their PowerShell 7 profile as ordinary commands: ask, fix, brief, mem and news.

The model runs through Ollama on loopback only, at http://127.0.0.1:11434. If the endpoint is not local, the command fails closed. A helper builds a structured context packet with the time, machine health, current directory, last error, git status and recent history, then the model answers in place.

Every destructive suggestion is shown, never executed. Mutating cmdlets in the full module require -Confirm or ShouldProcess and are logged. The stack is PowerShell 7.2 or later (7.6 LTS recommended), qwen2.5:7b as the default chat model, nomic-embed-text for local vector memory, and Pester 5+ for tests.

Setup

  • PowerShell 7.2+ (7.6 LTS recommended)
  • Ollama on 127.0.0.1:11434
  • qwen2.5:7b as the default model in the sample and in ops-settings.json
  • nomic-embed-text for the mem command
  • Pester 5+ for tests

How it works

  1. ask sends a prompt plus the ambient context packet to Ollama's /api/generate endpoint and prints the answer in the terminal.
  2. brief gathers processes, services, disk, network, firewall and Defender state, masks secrets, and asks the model for a structured analysis.
  3. fix can review a command or draft one in plain language, with the PowerShell version, installed modules and aliases included in the prompt.
  4. mem stores notes with nomic-embed-text embeddings. news fetches RSS or JSON feeds, filters them by topic keywords, and asks the model for a digest.
  5. Model output is never passed to Invoke-Expression. Sensitive text is masked before the packet is built, and every AI interaction is logged under Reports/.

Results & numbers

  • The author describes a working profile they use in the terminal, with verification steps rather than a speed benchmark.
  • A loopback check should show port 11434 open. With the network disconnected, ask and brief still work.
  • Setting a dummy SECRET_TOKEN and running brief should leave that token out of the logged packet. A fix prompt that suggests Remove-Item should return a suggestion and not run it.
  • The author's suggested tiers are phi3:mini under 1 second on 8 GB with no GPU, qwen2.5:7b in 2-4 seconds as a 16 GB CPU daily driver, qwen2.5:14b in 1-2 seconds on 32 GB RAM plus an 8 GB GPU, and a Q4 llama3.1:70b in 5-15 seconds on 48 GB or more of VRAM or 64 GB of unified memory. They recommend starting with qwen2.5:7b on 16 GB and say CPU-only 70B is unusable.

Gotchas

  • The news command fetches feeds from the network, then summarizes them locally. The author treats that fetched content as data, not as instructions.
  • Smaller models are faster but can slip on multi-step reasoning and long context, so the ambient packet has to be trimmed on the smaller tiers.
  • The hardware-and-model table is the author's sizing advice, not a timed run on each of those machines.
“My PowerShell 7 prompt is where I already live. Putting the LLM there means zero context switching and zero cloud.”— Shahriar Haque Abir

Do it yourself

  1. Install Ollama and pull a model, for example: ollama pull qwen2.5:7b.
  2. Add a function to your PowerShell profile ($PROFILE) that builds a context packet and POSTs to http://127.0.0.1:11434/api/generate, then alias it as ask.
  3. Fail closed if the endpoint is not loopback. Mask secrets before building the packet, and never run model output with Invoke-Expression.
  4. Optionally add brief, fix, mem and news the same way, and put the default model and aliases in a settings file.
  5. Confirm port 11434 is open, retry ask with the network disconnected, and check that a dangerous suggestion is displayed rather than executed.
# $PROFILE
function Invoke-OpsAI {
    param(
        [Parameter(Mandatory, Position = 0, ValueFromRemainingArguments)]
        [string[]]$Prompt,
        [switch]$Stream
    )
    $text = $Prompt -join ' '
    $ctx  = Get-AmbientContext
    $body = @{
        model  = 'qwen2.5:7b'
        prompt = "$ctx`n`nUser: $text"
        stream = $Stream.IsPresent
    } | ConvertTo-Json -Depth 6
    Invoke-RestMethod -Uri 'http://127.0.0.1:11434/api/generate' `
                      -Method POST -Body $body -ContentType 'application/json'
}
Set-Alias -Name ask -Value Invoke-OpsAI
Source: Shahriar Haque Abir on DEV · Published 2026-11-19 · Added 2026-11-19. This write-up summarizes the original source; see it for full details.

Similar setups

Getting OpenCode to work with a local Ollama model by fixing the 4,096-token context

OpenCode on a local Ollama model ignored files, invented tasks or looped, because each ~23k-token request was silently cut to fit Ollama's default 4,096-token context on a 16 GB GPU.

DEV Community (Davidrs) · 2026-11-27

MapNet: permission-aware local RAG over your folders on a CPU laptop with Ollama

Gal built MapNet, an MIT research prototype that keeps a live map of folders, files and sections so a small Ollama model only reads the few passages it needs, and published where it loses to embedding everything.

Gal on X · 2026-11-15

A Discord bot that answers with Qwen 2.5 3B on a CPU-only VPS

A Discord bot developer runs Ollama with Qwen 2.5 3B on the same 6-core VPS as the bot, with no GPU, so /ask answers and first ticket replies never go to a third party.

DEV Community (StellarDev) · 2026-11-24

A Meshtastic station that sends an honest automatic receipt when nobody answers

A Meshtastic user built a Python monitor that waits 90 seconds for a human to answer a radio check and, if nobody does, sends a clearly labeled automatic receipt, with a small Qwen3 model on Ollama only classifying messages.

X (@thatsatechnique) · 2026-11-20