question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extension auto-loads PowerShell modules

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

The PowerShell extension automatically loads the module in the root path See: https://github.com/PowerShell/vscode-powershell/issues/3457

PowerShell Version

Name                           Value                                                   
----                           -----                                                   
PSVersion                      5.1.19041.1023                                          
PSEdition                      Desktop                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                 
BuildVersion                   10.0.19041.1023                                         
CLRVersion                     4.0.30319.42000                                         
WSManStackVersion              3.0                                                     
PSRemotingProtocolVersion      2.3                                                     
SerializationVersion           1.1.0.1                                                 

Visual Studio Code Version

1.58.1
2aeda6b18e13c4f4f9edf6667158a6b8d408874b
x64

Extension Version

ms-vscode.powershell@2021.5.1
ms-vscode.powershell@2021.6.2

Then I tried Preview, same issue

ms-vscode.powershell-preview@2021.6.1

Steps to Reproduce

Open the dbatools repository in VS Code – it defaults to dev which has a new version of our library and SMO DLLs Open a PowerShell file in the repo Wait 1 minute (I’ve seen it in as little as 30 seconds) If it doesn’t do it, type Connect-DbaInstance, Switch to the fix-logshipping branch See that the DLLs are marked as changed

Visuals

vscode-powershell-load.zip

Logs

1626262647-8de0a045-410e-4ba9-ae60-726f5f65583e1626262644658.zip

Extra notes

I disabled all extensions except for my theme, PowerShell Preview and Settings Sync

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
potatoqualiteecommented, Jul 21, 2021

Ohh! This will be helpful, thank you. I did have some remnants of a postprofile function to delay the loading of things. brb

1reaction
potatoqualiteecommented, Jul 14, 2021

Was just troubleshooting some changes to our repo and got a note from a colleague that said VS Code loaded dbatools in his PATH and it was causing issues with his dbatools repo which had a different dll version. Once he Uninstall-Module, it gave no problems.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Script modules - PowerShell | Microsoft Learn
Script modules are an easy way to package scripts and functions ... The module autoloading feature was introduced in PowerShell version 3.
Read more >
Understanding PowerShell Modules
Almost all PowerShell commands live in modules, and by adding new modules to PowerShell, you can easily add more commands.
Read more >
8. Modules | PowerShell: Automating Administrative Tasks
Loading and unloading a module; PowerShell module autoloading ... Module files with a .psm1 extension are called script modules, for obvious reasons.
Read more >
Specific PowerShell Module Not Autoloading - Stack Overflow
Try reinstalling the module to see if that makes a difference. If that doesn't work, while it's annoying that the autoload isn't functioning ......
Read more >
Everything you wanted to know about PowerShell's Module ...
While working on some PowerShell scripts which are using AzureRM PowerShell modules for an Azure DevOps Extension I had some trouble using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found