Skip to content

Get-InstalledModule not working the same in v7.0 as in Windows PowerShell v5.1 #12271

Description

Steps to reproduce

PowerShell module Az is already installed on the system and can be confirmed in PS v5.1 using the same cmdlet.

Get-InstalledModule -Name Az

Expected behavior

Get-InstalledModule -Name Az

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
3.7.0      Az                                  PSGallery            Microsoft Azure PowerShell - Cmdlets to manage..

Actual behavior

Get-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9423
Line |
9423 |          PackageManagement\Get-Package @PSBoundParameters | Microsoft. …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | No match was found for the specified search criteria and module names 'Az'.

Environment data

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

The issue reads similarly to another that has been closed #12040

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Apr 7, 2020
  2. PaulBendall commented on Apr 7, 2020

    @PaulBendall
    Author

    Further to the issue:

    If I try to install the module in PWSH v7.0 it doesn't error but also doesn't install the module:

    install-module -name az
    
    Untrusted repository
    You are installing the modules from an untrusted repository. If you trust this repository, change its
    InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
    'PSGallery'?
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
    
    Get-InstalledModule -Name Az
    Get-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9423
    Line |
    9423 |          PackageManagement\Get-Package @PSBoundParameters | Microsoft. …
         |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         | No match was found for the specified search criteria and module names 'Az'.
    

    Trying to import the module appears to do something as the screen doesn't respond for a couple of minutes (about the length of time you'd expect it to take if the module was being imported). However, get-installedmodule still errors

    import-module -name az
    
    Get-InstalledModule -Name Az
    Get-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9423
    Line |
    9423 |          PackageManagement\Get-Package @PSBoundParameters | Microsoft. …
         |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         | No match was found for the specified search criteria and module names 'Az'.
    

    After importing, running Get-Module does list the module

    Get-Module
    
    ModuleType Version    PreRelease Name                                ExportedCommands
    ---------- -------    ---------- ----                                ----------------
    Script     3.7.0                 az
    Script     1.7.4                 Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefa…
    Script     1.1.1                 Az.Advisor                          {Disable-AzAdvisorRecommendation, Enable-AzAdviso…
    Script     1.0.3                 Az.Aks                              {Get-AzAks, Import-AzAksCredential, New-AzAks, Re…
    Script     1.1.2                 Az.AnalysisServices                 {Add-AzAnalysisServicesAccount, Export-AzAnalysis…
    Script     1.4.0                 Az.ApiManagement                    {Add-AzApiManagementApiToProduct, Add-AzApiManage…
    Script     1.0.3                 Az.ApplicationInsights              {Get-AzApplicationInsights, Get-AzApplicationInsi…
    Script     1.3.6                 Az.Automation                       {Export-AzAutomationDscConfiguration, Export-AzAu…
    Script     2.0.2                 Az.Batch                            {Disable-AzBatchAutoScale, Disable-AzBatchCompute…
    Script     1.0.2                 Az.Billing                          {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-A…
    Script     1.4.2                 Az.Cdn                              {Confirm-AzCdnEndpointProbeURL, Disable-AzCdnCust…
    etc.......
    
  3. PaulBendall commented on Apr 8, 2020

    @PaulBendall
    Author

    Further update based on more testing:

    Did a test with the module AzureAD which was originally installed under Admin context in PowerShell v5.1:

    1. In PS v5.1 > Get-InstalledModule -Name AzureAD
    2. < AzureAD module details
    3. In PS v7.0 > Get-InstalledModule -Name AzureAD
    4. < Error
    5. In PS v5.1 > get-module -ListAvailable -name AzureAD | select path
    6. < C:\Program Files\WindowsPowerShell\Modules\AzureAD\2.0.2.76\AzureAD.psd1
    7. In PS v7.0 > get-module -ListAvailable -Name AzureAd | select Path
    8. < C:\Program Files\WindowsPowerShell\Modules\AzureAD\2.0.2.76\AzureAD.psd1
    9. In PS v5.1 > Uninstall-Module -Name AzureAD -AllVersions -Force
    10. In PS v7.0 > install-module -name AzureAd
    11. In PS v7.0 > get-module -ListAvailable -Name AzureAd | select Path
    12. < C:\Users\paul-local\Documents\PowerShell\Modules\AzureAD\2.0.2.76\AzureAD.psd1
    13. Now in PS v7.0 > Get-InstalledModule -name AzureAD
    14. < AzureAD Module details
    15. But in PS V5.1 we now get an error with Get-INstalledModule and Get-Module can't find the AzureAD module that was installed under v7.0
  4. iSazonov commented on Apr 8, 2020

    @iSazonov
    Collaborator

    AzureAD is not compatible with PowerShell Core, only Az.

    I guess the issue with Az due to WinCompat feature. /cc Andrew (@anmenaga)
    Try to uninstall Az module from Windows PowerShell and leave it only in PowerShell Core.

  5. anmenaga commented on Apr 8, 2020

    @anmenaga

    Looks like module paths are outside of System32, so implicit WinCompat should not auto-engage unless module uses WinPS-only cmdlets during import (relatively rare situation). A way to check that:

    1. start a fresh PS 7.0
    2. import-module -name az #assuming there are no errors here
    3. Get-PSSession
    4. if there are no PS sessions returned - WinCompat was not used.
    5. Get-Module -Name az | select ModuleType,Version # if WinCompat was used, then ModuleType would be Script and Version would be 1.0

    alerickson Have you seen such errors from Get-Package/PowerShellGet ?

    Paul Bendall (@PaulBendall) also, what is the value of $env:PSModulePath in a fresh PS 7.0 ?

  6. MaximoTrinidad commented on Apr 8, 2020

    @MaximoTrinidad

    Just an FYI

    Its been mention, in recent posts about AzureAD module, it can work using the Import-Module with the "-UseWindowsPowerShell" parameter.

    Still, this is just a way to make it work until the AD Team (not Azure) can make it work with PowerShell 7.

    :)

  7. alerickson commented on Apr 9, 2020

    @alerickson
    Member

    Paul Bendall (@PaulBendall) I think this is happening because the Az module was originally installed in WindowsPS. I can repro that way, but don't have any issues if installing in in Core (and vice versa). PSGet seems to be only looking at the module paths for that particular edition of PS. This scenario is also currently failing with the beta version of PowerShellGet 3.0, so I'll open an issue there to address it.

    For your issue with installing try running
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    first and then let me know if installation is successful.

  8. kilasuit commented on Dec 10, 2020

    @kilasuit
    Collaborator

    This is not a PowerShell issue but actually a PowerShellGetv2 issue and this issue should be transferred to that repository

  9. davesbrown commented on Mar 2, 2022

    @davesbrown

    Not sure of status here, being as still open, but Ryan Yates (@kilasuit) says it should go to PowerShellGetv2 team, but I've just noticed this bug behavior with

    Get-InstalledModule dbatools
    

    I was able to install to latest, and Get-Module does show the latest installed

  10. ThomasNieto commented on Aug 18, 2023

    @ThomasNieto
    Contributor

    Sydney Smith (@SydneyhSmith) can this issue be closed/moved to the PSGet v2 repository?

  11. kilasuit commented on Aug 19, 2023

    @kilasuit
    Collaborator

    Closing this as a duplicate of PowerShell/PowerShellGetv2#684 (which is a newer repro of this issue)

  12. microsoft-github-policy-service commented on Aug 20, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.

  13. microsoft-github-policy-service commented on Aug 20, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes.

  14. SydneyhSmith commented on Aug 21, 2023

    @SydneyhSmith
    Contributor

    Steve Lee (@SteveL-MSFT) can you please transfer or give me transfer rights in this repo 😄

  15. d3xtr01D commented on Sep 1, 2023

    @d3xtr01D

    I'm facing the oposite problem. Get-InstalledModule it's working fine but when I try to uninstall a module, it seems to do it but it don't

    Uninstall-Module -Name AzureAd -Verbose -Force
    VERBOSE: Performing the operation "Uninstall-Module" on target "Version '2.0.2.140' of module 'AzureAD'".
    VERBOSE: Successfully uninstalled the module 'AzureAD' from module base 'C:\Users\MyFolder\Documents\PowerShell\Modules\AzureAD\2.0.2.140'.

    I restart the console and

    Get-InstalledModule -Name AzureAD

    Version Name Repository Description


    2.0.2.140 AzureAD PSGallery Azure Active Directory V2 General Availability Module.…

    Its still there.

    How can I remove completely any module from pwsh.exe? Any help would be appreciate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-PowerShellGetspecific to PowerShellGet moduleIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-DuplicateThe issue is a duplicate.Resolution-ExternalThe issue is caused by external component(s).

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions