Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Powershell 7 Get-InstalledModule not working #684

Open
3 tasks done
BohrenAn opened this issue Oct 18, 2022 · 7 comments
Open
3 tasks done

Powershell 7 Get-InstalledModule not working #684

BohrenAn opened this issue Oct 18, 2022 · 7 comments

Comments

@BohrenAn
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

As you can see below, i am using PowerShell 7. Seems that Get-InstalledModule does not work there.
Get-Module does work.

See also: PowerShell/PowerShell#12271

PS C:> get-host

Name : ConsoleHost
Version : 7.2.6
InstanceId : fd07e65c-c9a5-4e9a-b473-661fc858c9a1
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-CH
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

PS C:> Get-InstalledModule MicrosoftTeams
Get-Package: No match was found for the specified search criteria and module names 'MicrosoftTeams'.

PS C:> Get-Module MicrosoftTeams -ListAvailable

Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version PreRelease Name PSEdition ExportedCommands


Script 4.8.0 MicrosoftTeams Core,Desk {Add-TeamChannelUser, Add-TeamUser, Connect-MicrosoftTeams, Disconnect-MicrosoftTeams…}

PS C:> Get-Module PowerShellGet -ListAvailable

Directory: C:\Users\andres.bohren\OneDrive - ISOLUTIONS AG\Documents\PowerShell\Modules

ModuleType Version PreRelease Name PSEdition ExportedCommands


Binary 3.0.17 beta17 PowerShellGet Desk {Find-PSResource, Get-PSResource, Get-PSResourceRepository, Install-PSResource…}

Directory: C:\program files\powershell\7\Modules

ModuleType Version PreRelease Name PSEdition ExportedCommands


Script 2.2.5 PowerShellGet Desk {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…}

Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version PreRelease Name PSEdition ExportedCommands


Binary 3.0.17 beta17 PowerShellGet Desk {Find-PSResource, Get-PSResource, Get-PSResourceRepository, Install-PSResource…}
Script 2.2.5 PowerShellGet Desk {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…}
Script 1.0.0.1 PowerShellGet Desk {Install-Module, Find-Module, Save-Module, Update-Module…}

PS C:>

Expected behavior

Get-InstalledModule -Name <ModuleName> #Returns Information about installed Module

Actual behavior

Get-InstalledModule -Name <ModuleName>
Returns the Error:
Get-Package: No match was found for the specified search criteria and module names 'MicrosoftTeams'.

Error details

No response

Environment data

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

PowerShellGet 2.2.5

Visuals

image

@alerickson
Copy link
Member

Thanks for letting us know of this issue @BohrenAn! Are you encountering this issue with Get-PSResource in PowerShellGet 3.0.17-beta17? We're currently only adding security bug fixes to PowerShellGet v2, but will address any v2 issues or bugs in v3.

@BohrenAn
Copy link
Author

@alerickson
I did run the following command. No return value. Does this help?

PS C:\Users\a.bohren> Get-PSResource -Name MicrosoftTeams
PS C:\Users\a.bohren> Get-Module

ModuleType Version PreRelease Name ExportedCommands


Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-It…
Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Ob…
Script 1.4.7 PackageManagement {Find-Package, Find-PackageProvider, Get-Package,…
Script 2.2.5 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Fin…
Binary 3.0.17 beta17 PowerShellGet {Find-PSResource, Get-PSResource, Get-PSResourceR…
Script 2.1.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, …

@anamnavi
Copy link
Member

anamnavi commented Nov 7, 2022

@BohrenAn thanks for sharing this info! There's 2 aspects to it. Firstly, with searching for packages installed under "Program Files" included in the path, that denotes machine wide scope, so to search for it you would need to add -Scope AllUsers (instead of the default which is CurrentUser). So an example would be Get-PSResource -Name "PowerShellGet" -Scope AllUsers.

Secondly, modules/scripts installed on WindowsPowerShell (i.e they have "WindowsPowerShell" included in their path), would not be accessible from PowerShell6+. But, modules/scripts installed on PowerShell6+ are accessible from WindowsPowerShell. For you to resolve your issue, if you can install MicrosoftTeams through PowerShell7 then it should be discoverable and accessible with Get-PSResource. Please let us know if that works, thanks!

@BohrenAn
Copy link
Author

BohrenAn commented Nov 8, 2022

PowerShell 7 started as Administrator

PS C:\> get-host
Name             : ConsoleHost
Version          : 7.2.7
InstanceId       : 9a2e4618-12e0-45ad-8558-dfdd8e1e91ba
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-CH
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

PS C:\> Get-InstalledModule Icewolf.EXO.Spamanalyze
Get-Package: No match was found for the specified search criteria and module names 'Icewolf.EXO.Spamanalyze'.

PS C:\> Install-Module Icewolf.EXO.Spamanalyze -Scope AllUsers
PS C:\> Get-InstalledModule Icewolf.EXO.Spamanalyze
Get-Package: No match was found for the specified search criteria and module names 'Icewolf.EXO.Spamanalyze'.

PS C:\> Install-Module Icewolf.EXO.Spamanalyze -Scope CurrentUser
PS C:\> Get-InstalledModule Icewolf.EXO.Spamanalyze
Get-Package: No match was found for the specified search criteria and module names 'Icewolf.EXO.Spamanalyze'.

It works with the MicrosoftTeams Module

PS C:\> Get-InstalledModule MicrosoftTeams | fl Name, Version, InstalledLocation
Name              : MicrosoftTeams
Version           : 4.9.0
InstalledLocation : C:\Program Files\PowerShell\Modules\MicrosoftTeams\4.9.0

With PowerShell 5

PS C:\> get-host
Name             : ConsoleHost
Version          : 5.1.19041.1682
InstanceId       : dde0cb43-049f-40cf-8d53-c5002aa1db09
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

PS C:\> Get-InstalledModule MicrosoftTeams | fl Name, Version, InstalledLocation
Name              : MicrosoftTeams
Version           : 4.9.0
InstalledLocation : C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\4.9.0

The Module is installed in two Directorys (has to be installed in each PowerShell Version separatly)

C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\4.9.0 (PowerShell 5)
C:\Program Files\PowerShell\Modules\MicrosoftTeams\4.9.0 (PowerShell 7)

But check this out (PowerShell 7)
PS C:\> get-InstalledModule PnP.PowerShell
Get-Package: No match was found for the specified search criteria and module names 'PnP.PowerShell'.

PS C:\> get-package PnP.PowerShell
Get-Package: No package found for 'PnP.PowerShell'.

PS C:\> install-Module PnP.PowerShell
WARNING: Version '1.9.0' of module 'PnP.PowerShell' is already installed at 'C:\Program Files\WindowsPowerShell\Modules\PnP.PowerShell\1.9.0'. To install version '1.11.0', run Install-Module and add the -Force parameter, this command will install version '1.11.0' side-by-side with version '1.9.0'.
PS C:\>

Seems to be that you can install some Modules and some not.
Some modules you can load even if they are installed in "C:\Program Files\WindowsPowerShell\Modules"

PS C:\> get-module
ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Manifest   7.0.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}
Manifest   7.0.0.0               Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSig…
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Script     1.4.7                 PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider…}
Script     2.2.5                 PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability…}
Script     2.1.0                 PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, S…

PS C:\> import-module PnP.PowerShell
PS C:\> get-module

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Manifest   7.0.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}
Manifest   7.0.0.0               Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSig…
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Script     1.4.7                 PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider…}
Manifest   1.9.0                 PnP.PowerShell                      {Add-PnPAlert, Add-PnPApp, Add-PnPApplicationCustomizer, Add-PnPAzureADGroupMem…
Script     2.2.5                 PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability…}
Script     2.1.0                 PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, S…

It's not consistent in any way. And i am not able to install several Modules in PowerShell 7. Find it very confusing...

@anamnavi
Copy link
Member

@BohrenAn we completely understand the frustration with this PowerShellGet V2 behavior. We are working on PowerShellGet V3 to be less confusing and handle such scenarios better. If you try finding the installed MicrosoftTeams package with the PowerShellGetV3 cmdlet Get-PSResource like such: Get-PSResource -Name "MicrosoftTeams" -Scope AllUsers are you able to find it?

@BohrenAn
Copy link
Author

BohrenAn commented Nov 22, 2022

Hi @anamnavi

Install-Module in PowerShell 5 is default to AllUsers?
Install-Module in PowerShell 7 is default to CurrentUser?
Did i get that right?

Here is the Output you asked for in PowerShell 7

PS C:> Get-Module
ModuleType Version PreRelease Name ExportedCommands


Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}
Manifest 7.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, …
Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Script 1.4.8.1 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-Packag…
Binary 3.0.17 beta17 PowerShellGet {Find-PSResource, Get-PSResource, Get-PSResourceRepository, …
Script 2.2.5 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCapab…
Script 2.2.6 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSRe…

PS C:> Get-InstalledModule -Name "MicrosoftTeams"
Version Name Repository Description


4.9.0 MicrosoftTeams PSGallery Microsoft Teams cmdlets module for Windows PowerShe…

PS C:> Get-PSResource -Name "MicrosoftTeams" -Scope AllUsers
Name Version Prerelease Repository Description


MicrosoftTeams 4.9.0 PSGallery Microsoft Teams cmdlets module for Windows PowerShell and PowerShell Core.…

PS C:> Get-PSResource -Name "MicrosoftTeams" -Scope CurrentUser
PS C:>

image

@anamnavi
Copy link
Member

@BohrenAn
PSGet 2.2.5 (and its cmdlet Install-Module) defaults to CurrentUser for PowerShell5 and 7.
Lower versions of PSGet may not default to CurrentUser.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants