Skip to content

[Az.Tools.Installer] [Microsoft.PowerShell.Commands.PSRepositoryItemInfo] does not contain a method named 'Where' #13167

@brwilkinson

Description

@brwilkinson

Description

Update-AzModule fails in WindowsPowerShell 5.1

Method invocation failed because [Microsoft.PowerShell.Commands.PSRepositoryItemInfo] does not contain a method named 'Where'.
At D:\OneDrive\Documents\PowerShell\Modules\Az.Tools.Installer\0.1.0\internal\Get-AzModuleUpdateList.ps1:50 char:17

image

Steps to reproduce

(PowerShellGet\Get-InstalledModule -Name az.storage -AllVersions).where({$true})

> Method invocation failed because [Microsoft.PowerShell.Commands.PSRepositoryItemInfo] does not contain a method named 'Where'.

# Turning the returned object into an array should resolve the issue ???

@(PowerShellGet\Get-InstalledModule -Name az.storage -AllVersions).where({$true})


Version              Name                                Repository           Description
-------              ----                                ----------           -----------
2.6.0                Az.Storage                          PSGallery

Environment data

$PSVersionTable 

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

Module versions

gmo p*t

Script     1.4.7      PackageManagement
Script     2.2.5      PowerShellGet

Debug output

 Update-AzModule                                                                                                                                                                              
DEBUG: Powershell Desktop Version 5.1.20211.1000
DEBUG: Retrieving installed Az modules
DEBUG: 00:00:00.0000001 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0000234 ErrorAction: Stop
DEBUG: 00:00:00.0000354 Name: Az*
DEBUG: 00:00:00.0010377 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0018715 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0038547 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0069276 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0069476 ErrorAction: Stop
DEBUG: 00:00:00.0069594 Name: Az*
DEBUG: 00:00:00.0077967 INVOKING PowerShell Fn Get-DynamicOptions with args Install that has length 1
DEBUG: 00:00:00.0086506 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0148213 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0368594 Calling New() : MethodName = 'GetInstalledPackages'
DEBUG: 00:00:00.0403776 ProviderName: PowerShellGet
DEBUG: 00:00:00.0431741 Type: Module
DEBUG: 00:00:00.0455515 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.0474389 Name: Az*
DEBUG: 00:00:00.0490409 ErrorAction: Stop
DEBUG: 00:00:00.0506963 INVOKING PowerShell Fn Get-InstalledPackage with args Az*, , ,  that has length 4
DEBUG: 00:00:00.0543650 In PowerShellGet Provider - 'Get-InstalledPackage'.
DEBUG: 00:00:00.0564219 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:00.0591170 OPTION: Type => Module
DEBUG: 00:00:00.0612751 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.0634222 OPTION: Name => Az*
DEBUG: 00:00:00.0651344 OPTION: ErrorAction => Stop
DEBUG: 00:00:02.6630485 Done calling powershell «Get-InstalledPackage» «PSModule»
DEBUG: The Az modules currently installed: Az.Network Az.CognitiveServices Az.SignalR Az.Storage Az.RecoveryServices Az.HDInsight Az.MachineLearning Az.OperationalInsights Az.DataLakeStore Az.Compute Az.Cdn
Az.Batch Az.RedisCache Az.Monitor Az.ApiManagement Az.Billing Az.StorageSync Az.DevTestLabs Az.StreamAnalytics Az.NotificationHubs Az.Functions Az.DeploymentManager Az.Automation Az Az.Aks
Az.ContainerRegistry Az.DesktopVirtualization Az.Advisor Az.DataShare Az.Support Az.DataBoxEdge Az.HealthcareApis Az.Websites Az.PowerBIEmbedded Az.SqlVirtualMachine Az.IotHub Az.KeyVault Az.FrontDoor
Az.LogicApp Az.Media Az.PrivateDns Az.AnalysisServices Az.ContainerInstance Az.MarketplaceOrdering Az.DataLakeAnalytics Az.DataFactory Az.EventHub Az.Maintenance Az.Dns Az.EventGrid Az.ApplicationInsights
Az.ServiceBus Az.Resources Az.Relay Az.Sql Az.ServiceFabric Az.PolicyInsights Az.Accounts Az.Kusto Az.ManagedServices Az.TrafficManager
DEBUG: 00:00:00.0000001 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0000231 AllVersions: True
DEBUG: 00:00:00.0000349 Name: Az.Network
DEBUG: 00:00:00.0007970 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0015762 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0027943 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0063125 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0063323 AllVersions: True
DEBUG: 00:00:00.0063445 Name: Az.Network
DEBUG: 00:00:00.0070382 INVOKING PowerShell Fn Get-DynamicOptions with args Install that has length 1
DEBUG: 00:00:00.0078811 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0137098 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0500503 Calling New() : MethodName = 'GetInstalledPackages'
DEBUG: 00:00:00.0535997 AllVersions: True
DEBUG: 00:00:00.0555197 Type: Module
DEBUG: 00:00:00.0566768 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.0578549 Name: Az.Network
DEBUG: 00:00:00.0590653 ProviderName: PowerShellGet
DEBUG: 00:00:00.0605627 INVOKING PowerShell Fn Get-InstalledPackage with args Az.Network, , ,  that has length 4
DEBUG: 00:00:00.0629242 In PowerShellGet Provider - 'Get-InstalledPackage'.
DEBUG: 00:00:00.0646467 OPTION: AllVersions => True
DEBUG: 00:00:00.0664850 OPTION: Type => Module
DEBUG: 00:00:00.0680698 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.0694075 OPTION: Name => Az.Network
DEBUG: 00:00:00.0706144 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:01.7502390 Done calling powershell «Get-InstalledPackage» «PSModule»
Method invocation failed because [Microsoft.PowerShell.Commands.PSRepositoryItemInfo] does not contain a method named 'Where'.
At D:\OneDrive\Documents\PowerShell\Modules\Az.Tools.Installer\0.1.0\internal\Get-AzModuleUpdateList.ps1:50 char:17
+ ...             $installedModules = (PowerShellGet\Get-InstalledModule -N ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Where:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

DEBUG: 00:00:00.0000001 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0000189 AllVersions: True
DEBUG: 00:00:00.0000310 Name: Az.CognitiveServices
DEBUG: 00:00:00.0008163 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0016061 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0029037 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0059240 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0059429 AllVersions: True
DEBUG: 00:00:00.0059544 Name: Az.CognitiveServices
DEBUG: 00:00:00.0066704 INVOKING PowerShell Fn Get-DynamicOptions with args Install that has length 1
DEBUG: 00:00:00.0074695 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0120148 Done calling powershell «Get-DynamicOptions» «PSModule»
DEBUG: 00:00:00.0483526 Calling New() : MethodName = 'GetInstalledPackages'
DEBUG: 00:00:00.0506664 AllVersions: True
DEBUG: 00:00:00.0524101 Type: Module
DEBUG: 00:00:00.0545386 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.0573626 Name: Az.CognitiveServices
DEBUG: 00:00:00.0589303 ProviderName: PowerShellGet
DEBUG: 00:00:00.0608890 INVOKING PowerShell Fn Get-InstalledPackage with args Az.CognitiveServices, , ,  that has length 4
DEBUG: 00:00:00.0632911 In PowerShellGet Provider - 'Get-InstalledPackage'.
DEBUG: 00:00:00.0648190 OPTION: AllVersions => True
DEBUG: 00:00:00.0663640 OPTION: Type => Module
DEBUG: 00:00:00.0683458 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:00.0700005 OPTION: Name => Az.CognitiveServices
DEBUG: 00:00:00.0718940 OPTION: ProviderName => PowerShellGet

Error output

Resolve-AzError                                                                                                                                                                            ⨯ ⚡ 20:49:48
DEBUG: 8:49:50 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 8:49:50 PM - using account id 'benwilk@microsoft.com'...
WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release.  Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.


   HistoryId: -1


Message        : Method invocation failed because [Microsoft.PowerShell.Commands.PSRepositoryItemInfo] does not contain a method named 'Where'.
StackTrace     :    at System.Management.Automation.Language.PSInvokeMemberBinder.InvokeAdaptedMember(Object obj, String methodName, Object[] args)
                    at lambda_method(Closure , Object[] , StrongBox`1[] , InterpretedFrame )
Exception      : System.Management.Automation.RuntimeException
InvocationInfo : {}
Line           :                 $installedModules = (PowerShellGet\Get-InstalledModule -Name $key -AllVersions).Where( { -not $_.AdditionalMetadata.IsPrerelease })

Position       : At D:\OneDrive\Documents\PowerShell\Modules\Az.Tools.Installer\0.1.0\internal\Get-AzModuleUpdateList.ps1:50 char:17
                 + ...             $installedModules = (PowerShellGet\Get-InstalledModule -N ...
                 +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : -1


The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.

DEBUG: AzureQoSEvent: CommandName - Resolve-AzError; IsSuccess - True; Duration - 00:00:00.0415010;
DEBUG: Finish sending metric.
DEBUG: 8:49:51 PM - ResolveError end processing.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions