PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.72k stars 494 forks source link

Issue with PowerCLI in Powershell Extension - Intellisense #422

Closed cajunitalian closed 7 years ago

cajunitalian commented 7 years ago

Please fill in these details so that we can help you!

System Details

Name                           Value
----                           -----
PSVersion                      5.0.10240.17146
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.42000
BuildVersion                   10.0.10011.16384
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3

Issue Description

Unable to use intellisense w/ PowerCLI Module Cmdlets. See my screenshot, you'll see the PowerCLI Module path is clearly in $env:PSModulePath (C:\VMware\Infra\PowerCLI\Modules)*

*Yes, I am writing in a .ps1 file. Powershell is working, just not intellisense for that module.

Attached Logs

Attached Screenshots

Here's an example of the module paths, showing that $env is good

image

Here's an example of Connect-VIServer, you can see it's not working.

image

daviwil commented 7 years ago

Hey Matteo, you might need to load the module into the session before IntelliSense appears. For now the best way to do this is add Import-Module PowerCLI to your VS Code profile:

$HOME\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1

After adding that, restart VS Code and you should get IntelliSense for the module.

cajunitalian commented 7 years ago

That profile doesn't exist - how can I create it? Do I just manually build it?

I know in typical POSH you just run the commands but the integrated terminal in VSC is using my local logged in AD Profile which has it's own POSH Profile.

*Micorsoft.Powershell_profile.ps1

rkeithhill commented 7 years ago

Create it like so:

notepad $home\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1

Notepad should ask you if you want to create the file. Then add the one line Import-PowerCLI and save & exit the file. This profile is specific to the PowerShell extension for VSCode so when you are editing scripts, that profile gets processed which should load this module for you.

cajunitalian commented 7 years ago

That did the trick. Thanks guys, trying to convert from heavy VS2016 over the VSC