Repository navigation
Get-InstalledModule not working the same in v7.0 as in Windows PowerShell v5.1 #12271
Description
Activity
- addedIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
on Apr 7, 2020 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 azUntrusted 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"): yGet-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 azGet-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.......Further update based on more testing:
Did a test with the module AzureAD which was originally installed under Admin context in PowerShell v5.1:
- In PS v5.1 > Get-InstalledModule -Name AzureAD
- < AzureAD module details
- In PS v7.0 > Get-InstalledModule -Name AzureAD
- < Error
- In PS v5.1 > get-module -ListAvailable -name AzureAD | select path
- < C:\Program Files\WindowsPowerShell\Modules\AzureAD\2.0.2.76\AzureAD.psd1
- In PS v7.0 > get-module -ListAvailable -Name AzureAd | select Path
- < C:\Program Files\WindowsPowerShell\Modules\AzureAD\2.0.2.76\AzureAD.psd1
- In PS v5.1 > Uninstall-Module -Name AzureAD -AllVersions -Force
- In PS v7.0 > install-module -name AzureAd
- In PS v7.0 > get-module -ListAvailable -Name AzureAd | select Path
- < C:\Users\paul-local\Documents\PowerShell\Modules\AzureAD\2.0.2.76\AzureAD.psd1
- Now in PS v7.0 > Get-InstalledModule -name AzureAD
- < AzureAD Module details
- 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
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.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:
- start a fresh PS 7.0
import-module -name az#assuming there are no errors hereGet-PSSession- if there are no PS sessions returned - WinCompat was not used.
Get-Module -Name az | select ModuleType,Version# if WinCompat was used, then ModuleType would beScriptand Version would be1.0
alerickson Have you seen such errors from
Get-Package/PowerShellGet?Paul Bendall (@PaulBendall) also, what is the value of
$env:PSModulePathin a fresh PS 7.0 ?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.
:)
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.Reacted by IlyaThis is not a PowerShell issue but actually a PowerShellGetv2 issue and this issue should be transferred to that repository
- addedArea-PowerShellGetspecific to PowerShellGet modulespecific to PowerShellGet module
on Jan 16, 2021 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 dbatoolsI was able to install to latest, and Get-Module does show the latest installed
ThomasNieto commented
on Aug 18, 2023 ContributorMore actionsSydney Smith (@SydneyhSmith) can this issue be closed/moved to the PSGet v2 repository?
- addedResolution-DuplicateThe issue is a duplicate.The issue is a duplicate.Resolution-ExternalThe issue is caused by external component(s).The issue is caused by external component(s).
on Aug 19, 2023 Closing this as a duplicate of PowerShell/PowerShellGetv2#684 (which is a newer repro of this issue)
microsoft-github-policy-service commented
on Aug 20, 2023 ContributorMore actionsThis issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.
microsoft-github-policy-service commented
on Aug 20, 2023 ContributorMore actionsThis issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes.
SydneyhSmith commented
on Aug 21, 2023 ContributorMore actionsSteve Lee (@SteveL-MSFT) can you please transfer or give me transfer rights in this repo 😄
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.
Steps to reproduce
PowerShell module Az is already installed on the system and can be confirmed in PS v5.1 using the same cmdlet.
Expected behavior
Actual behavior
Environment data
The issue reads similarly to another that has been closed #12040