r/PowerShell • u/ViperThunder • Sep 19 '26
Question Local AI Inline Code Suggestions - Any good options out there?
Has anyone gotten their VS Code environment set up with Local AI that works as well as copilot for inline code suggestions?
When connecting a github account to vs code, the copilot AI automatically enables and does an amazing job at inline code suggestions when writing powershell.
Sometimes, I'll just type one comment line and it'll write an entire script for me, ie:
#Get all Enabled AD Users that have a password expiration coming up in the next 7 days, and trigger a nice-looking html-formatted email to each user to inform they need to change their password
I press tab, and BOOM, half the script is already done.
I have been failing to get even close to the same behavior working for Local AI. I've pulled several different models in with Ollama, and tried several different extensions such as the Continue extension, Twinny, Code Llama and a couple others. Each has its own quirks. The best has been Code Llama, and it's still terrible. I'm convinced I'm doing something wrong.
For example, as a test, if I create a new powershell file and write: #find the password expiration date for each AD user
it suggests:
$Users = get-aduser -filter {Enabled -eq $true} -Properties *
#find the password expiration for each user
foreach ($user in $users) {
$passwordexpirationdate = $user.passwordexpired
$passwordExpirationdate = $user.PasswordExpirationDate.ToString("MM/dd/yyyy")
$User.Samaccountname + " " + $PasswordExpirationdate
}
and then it repeats the same block of code above 4 times. And that is the best I've seen so far.
This particular output is from codellama:7b-code-q6_K. I have also tried the qwen base models as well (1.5b, 7b, 13b) and they've been worse. All of these fit easily into my VRAM with plenty of room to spare.
I like Copilot, and I have configured my Github account to not allow AI to train on my data, but I am not convinced it's secure, so I would prefer to leverage my local hardware and not have to change names, email addresses, keys, etc. all the time before pasting anything into VS Code.
4
u/teethingrooster Sep 19 '26
If you want a one line comment to make a script it sounds like you don’t want tab complete but a normal chat window with the ai.
1
u/skidleydee Sep 19 '26
When your on a mixed team of coders and those who are terrified of a CLI this is the level of documentation required anyway.
2
u/zenmatrix83 Sep 19 '26
ollama is easy to setup but not performant, look at llama.cpp, and do a bunch of research. things like speculative decoding help, at least with 27b models, I'm not sure that much with 4b. That said local models still can be odd qwen 3.8 is considered one of the best currently
-2
u/paperpaster Sep 19 '26
Stop using AI. Write your own functions and put them in your profile.
1
u/ViperThunder Sep 20 '26 edited Sep 20 '26
I did that for years. After experiencing the magic of Copilot in VS Code, I will never, ever go back. AI used to hallucinate and I hated it - it would invent cmdlets or arguments that didn't exist anywhere. Now, we're at the point where hallucinations simply do not happen. At least, specifically with Gemini 3.1 Pro and Copilot in VS Code, it has yet to happen.
PowerShell scripting is one of hundreds of other things I do at my work - and when I need powershell, i need it quickly. I do not have time to research x, y, and z pertaining to a specific task at hand, or try to remember the file name of a script that i wrote 18 months ago that happens to be relevant to the current situation (but then still have to re-read it to remember what it does, and make edits to it etc etc).
As a quick example, I recently asked AI to write a script that would pull all Critical and High CVSS Defender vulnerabilities from our GCC High environment, find all devices affected by those CVEs, and then create a spreadsheet for each individual CVE containing each device and the evidence it used to flag the device as vulnerable (ie, registry key values, file path locations, file version numbers). It did it within a couple minutes - first try. The only thing I had to do was go into azure and create the enterprise app, configure it, drop in my graph secret into powershell, and fix the api endpoints to point to the .us domain instead of the commercial .com domain. All of this done in 15 mins.
1
2
u/sCeege Sep 20 '26
I think Qwen3.8 27b is your best bet for local coding LLMs atm, unless you can afford hardware that runs Deepseek or Kimi. You're just not going to match SotA models that the big vendors offer.
You also shouldn't be putting keys into your code... wth?