Intellisense does not seem to be working

Hi, brand new PS guy here. I am following along in “Learn PowerShell in a Month of Lunches”, 4th Edition. I’m way early in the book getting the look and feel of VS Code. It talks about Intellisense but it does not seem to be working for me. I’m running Windows 11 Pro on a Dell Precision Workstation Laptop. Tabbing brings up the suggestions just fine; I cannot figure out how to make Intellisense work.

Did you set the prediction source to history?

Set-PSReadlineOption -PredictionSource History

I did. No effect. I even tried installing “npm Intellisense”. It does not seem to work either.

I wouldn’t mess with ‘npm’ intellisense. What version of PSReadline do you have? Are you running this in PS 7 or 5? Have you tried updating it? Note that different PSreadline versions might be setup in different PS versions.

Get-Module PSReadline Should give the version.

I have Set-PSReadLineOption -PredictionSource History set in my profile (not sure if that’s necessary anymore tbh). Predictive Intellisense was added i think in 2.1 per Announcing PSReadLine 2.1+ with Predictive IntelliSense - PowerShell Team (microsoft.com).

As far as getting it to work, I don’t think there’s anything else to it, other than setting that option. I’d start with updating the module (and making sure the module is installed), then adding Set-PSReadlineOption -PredictionSource History to your PS profile.

Then run a command, then type in that same command and see if it gives you the previous as a suggestion.

That command yields Version 2.3.4. I’m using PS 7.4. I’m now getting historical commands predicted. Just not any newer stuff.

Could you explain what you mean by that? Can you explain what you you are trying to accomplish? Perhaps it is working but you’re expecting something different. Predictive Intellisense works based on historical (or plugin) commands:

image

Because I’ve wrote that command before, it’s now suggesting it (I’m using inline view)

Using predictors in PSReadLine - PowerShell | Microsoft Learn

Sorry if I’m not being clear. As I said before, I am following along in “Learn PowerShell in a month of lunches”, 4th Ed, by Petty, Plunk, Leonhardt, Jones, and Hicks. Early in the book (so not much history there), it’s having me go through some basic exercises and its showing the predictive nature of Intellisense, and my screen is not looking like the screen shots in the book. The book suggests this forum to look for help so here I am. I’m not a complete coding neophyte; I’ve worked in C, C++, Pascal, Fortran, and VBA. But its been a while and I’m new to PowerShell. I’m just going through this book and asking questions as I go along.


The book seems to thing my Intellisense experience should look like this.

But it does work as you describe for historical stuff.

No worries on being new! we all started new at some point in time :). I still consider myself new to PowerShell in a lot of ways, and I learn something new everyday :slight_smile:

I’m asking a lot of questions because I want to make sure I’m understanding what you’re seeing. Providing additional context/screenshots etc. sometimes can be very helpful since we can’t see your screen.

Your picture of the book helps (I haven’t read the book sorry!) I think what you’re seeing is just a different view.

try running:
Set-PSReadLineOption -PredictionViewStyle ListView

or you can hit the ‘F2’ Key that should toggle between inline and listview, which might be a helpful shortcut.

Well that was cool but it’s still limited to history. The book seems to think Intellisense is a different presentation of what you get from tabbing. Their example shows a list of all possible selections instead of one selection each time you tab. VBA kinda does that.

Intellisense is sort of an umbrella term. Predictive Intellisense - In a nutshell, you type a command, it’s in your psreadline history. Predictive intellisense will remember that and can ‘suggest’ it for future commands if what you type matches it. Many of us write oen off commands and we use them a lot without thinking, Predictive intellisense can help quickly write those again. From the picture you provided, the book shows an example of typing a command (Get-Ex) and seeing a history of commands that have been ran before by the individual. Mine for that same command will be a different list, because I may not use the same commands.

It sounds like what you’re looking for is to type a incomplete command and be able to see all the possible commands that might match that criteria. You mentioned one way to do that already, using tab completion and continuing to hit tab to cycle through options. If you wanted a list, perhaps another option would be through the use of the Get-Command cmdlet. As an Example:

Get-Command -Name Get-Installed*

Will output out a list of commands that match that Get-Installed (* is wildcard). However, if this isn’t what you’re looking for, if you could answer my questions from my previous post (like what you’re expecting to happen/what the desired result is) along with some of the other questions, that’s going to help me help you. Otherwise, it’ll be difficult to assist.

I understand what you are saying but it’s not what the book is telling me. Here is a direct quote: “Visual Studio Code with the PowerShell extension offers the editor pane something like, but better than tab completion: IntelliSense. This feature operates in all four of the same situations we showed you for tab completions, except you get a cool little pop-up menu, like the one shown in figure 2.11.”

As far as what I am trying to do, nothing, specifically. I’m just following along in the book.

Could you share the page number of the book you’re reading form?

Never mind found it.

so you’re not getting this when you type a command, specifically in VS Code using the powershell extension:

image

The file you are in, it is a PS1 file yeah? and you are in the editor pane near the top? And confirmed the PS extension is installed?

That’s exactly what I am looking for. Attached are pictures of my screen so you can see that I’m in VSC, PS is the extension, and where I’m working. I don’t understand what you mean by “file”; I’m just on the text editor following along in the book. I’m actually working towards the bottom, as shown. You can see a partially completed command but no Intellisense :frowning_face:

I’m new so I’m limited to one picture per response. I’ll try multiple replies.

Yeah I follow you, thanks for the pictures. I’m going to preface this with, it sometimes ‘takes some time’ after opening a file for it to start working. It’s usually good after about a minute.

My screenshot isn’t of the terminal area which is where you are, it’s actually in a PS1 file that I opened with VS Code. The editor part of vs code is above the terminal, this area specifically by default from your SS:

image

So you don’t have a file open in VS code. I believe to get that functionality to work, the extension requires you do be in the ‘editor’ part by having a PowerShell file open (or PS needs to be the ‘selected language’. Here’s what you do:

  1. Create a file with a PS1 extension. You can manually do it or just run New-Item -Path .\Test.ps1 and that will create a Test.ps1 in the same directory right there in terminal.
  2. Open the file in VS Code. In your same terminal window you can run Code .\Test.ps1 or in VS Code (File → Open File
  3. Give it about a minute to make sure the plugin is fully ‘loaded’. It really does take a bit for it to start working.
  4. Type Get-C in the file and you should get that little drop down with commands.
1 Like

Well how about them apples? I wonder why the book left THAT little detail out? That was it. thank you!!