How to Use Local / Remote Ollama with PowerShell 7 on Windows
This guide shows you how to set up a custom PowerShell command to interact with your Ollama server from the Windows console.
Step 1: Install PowerShell 7
- Go to PowerShell GitHub Releases.
- Download the latest MSI installer for Windows (e.g., PowerShell-7.x.x-win-x64.msi).
- Run the installer and follow the prompts.
- Start PowerShell 7 by typing
pwsh in your Start menu or terminal.
Step 2: Set Up Your PowerShell Profile
-
Open PowerShell 7 (pwsh).
-
Run:
If prompted, create the file.
-
Paste the following function into the file: (replace model and uri with custom parameters)
-
Save and close Notepad.
-
Reload your profile by running:
Note
When you define a function (like ollama) in your profile, you can call it by typing its name in the console—this is known as a function-based command in PowerShell.
Step 3: Use Your Custom Command (Or alias)
- In PowerShell 7, type:
- Example:
- You'll see the combined response from your Ollama server.
Notes
- Make sure your Ollama server is running and accessible at the IP and port you specified.
- You can change the model name or server address in the function as needed.
- This command only sends text prompts and returns text responses.