Tool: Visual Studio CodePowerShell Module Version: PowerShellProTools 5.9.3 When i go into the PowerShell Pro Tools Module Explorer, it reports that are modules to update. When I click on the update button, the tool reports that it was updated, but... let's take SysInfo as an example. The explorer shows this, after I click the update button ![image|416x48](upload://r9FKhpkwB7iOp0FYTbaZbwCuikC.png) but if I look in the output file, I see these entries [8/12/2021 14:39:08] Executing command: Update-Module -Name 'SysInfo' -Force -AcceptLicense [8/12/2021 14:39:09] Error executing PowerShell: Module 'SysInfo' was not installed by using Install-Module, so it cannot be updated. [8/12/2021 14:39:09] Executing command: Get-Module -List -Name $SysInfo | Where-Object Version -eq '1.2.0' | Select-Object -ExpandProperty Path [8/12/2021 14:39:09] Error executing PowerShell: Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. I can see it not working for some reason or another, but it shouldn't tell me that is successfully completed. And most of the modules on my machine have been installed with Install-Module. Very weird that it reports that. Like with PowerShellProTools itself. I'm currently at 5.8.10, although 5.9.3 is available, but I get the same error - "not installed with Install-Module". But it was. Any ideas on what might be causing this weird behavior?
Are you running against Windows PowerShell 5.1?
It operates the same whether I’m using Windows PowerShell 5.1 or PowerShell 7.1.4.
Ok. I’ll open an issue so we can get resolved.
Excellent news. Let me know if I can provide any more information to you to help resolve this.
Did anything ever got done with this? And where do I see a list of open issues/bugs? is there such a thing?
Looks like this was resolved in the 2021.9.0 build. Sorry, I should have linked the issue when I created it to this forum post.
PoshProTools issues can be found here: Issues · ironmansoftware/issues · GitHub
Upcoming Milestones (next releases) can be found here: Milestones - ironmansoftware/issues · GitHub
So what could I be doing wrong? I’m running PowerShellproTools, v2021.10.0, from inside of Visual Studio code, and I’ve tried starting in both regular mode and as administrator, and I still get this, when I try to update Curl2PS and then dbatools. How can I debug this to find out what is wrong?
[10/27/2021 16:52:06] Executing command: Get-Module -List -Name $Curl2PS | Where-Object Version -eq ‘0.0.3’ | Select-Object -ExpandProperty Path
[10/27/2021 16:52:06] Error executing PowerShell: Cannot validate argument on parameter ‘Name’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
[10/27/2021 16:52:46] Executing command: Get-Module -List -Name $dbatools | Where-Object Version -eq ‘1.1.27’ | Select-Object -ExpandProperty Path
[10/27/2021 16:52:46] Error executing PowerShell: Cannot validate argument on parameter ‘Name’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
I see this error in the log too (found the source and fixed it) but the module updated for me:
Is the module updating for your or is it failing?
After I press the update button on, for example, PSReadLine, I see this in the PSPT module browser
But it doesn’t seem to take effect. I can run get-command, and see this in VS Studio code
or if I drop out to just a powershell window I see this
So I went searching for PSReadline 2.1.0, expecting it to be in C:\Users\DBOYD\Documents\PowerShell\Modules\PSReadline\2.1.0, but rather, found it here
So, PowerShellProTools sees that it was installed there, for god knows whatever reason, but my PowerShell doesn’t.
Should that strange path automatically be added to my path for searching for modules when I start PowerShell? Perhaps I have it messed up in my $profile file?
Weird. The PSReadLine module is a little strange because it ships with the PS extension and the PS extension loads it from the extension directory.
PS C:\src\poshtools\vscode\powershellprotools> (get-module psreadline).path C:\Users\adamr\.vscode\extensions\ms-vscode.powershell-preview-2021.10.1\modules\PSReadLine\2.1.0\PSReadLine.psm1
I wonder if calling Update-Module on that causes PSReadLine to be installed into the extension directory. Do all modules that you update appear in that module directory?
PoshTools is just calling Update-Module and not setting any PSModulePaths
How can I determine which PowerShell the update is supposed to be applied to? In other words, I have 5.1 and 7.1.5 installed. Is there some way to force which version is used in the module update?
It’s applying to whatever version of PowerShell that the PowerShell extension is using. You can click the version to change which one is running.
All right, thanks for the info. It almost looks like mine is getting confused. I’m going to do some testing over the weekend, and I’ll let you know what I find out.
Thanks for all your help.
When you look at $env:PSModulePath in your Powershell 7, does it include the modules from powershell 5.1? Mine does, but it seems to me that it probably shouldn’t?
I have no idea where I might have added those in, so I need to get looking. Unless you have that as well on your system.
I think PS7 does that automatically. I also have WindowsPowerShell modules in my path…
PS C:\Users\adamr> $env:psmodulepath C:\Users\adamr\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\PowerShell\Modules\;C:\PowerShell\Modules;C:\ProgramData\UniversalAutomation\Repository\Modules;
Then how does PowerShellTools know which to update? Does it check the path information to see if it matches with the version of PowerShell being run.
I still get the "not installed with Install-Module’ error.
I’m at a total loss as to why, but i think i remember that it all worked fine when i only had 5.1 on my machine.
What’s so funny 'bout peace, love, and understanding.
It strange because the reason we changed this functionality was that it was always calling Update-Module via 7.1 (the PoshToolsPro host process) rather than calling Update-Module in the loaded PS version.
I really don’t know why it’s not working for you but I’m more than happy to schedule a call to do some more debugging over Zoom. If that works, let me know and email me at email@example.com.
That would be great. This week I’m at Live!360 in Orlando, so this week is out. Next week is Thanksgiving, and you’re probably very busy.
Perhaps the week after that we can get together on zoon and see what is what.