Ankit
Ankit

Reputation: 21

" Get-InstalledModule -name az " Command gives 'No result Found'" But all Az commands works

I had to check if Az or AzureRM module is installed on some machines.

But I faced one issue where all Az commands work from PowerShell but when I execute Get-InstalledModule -name az it gives the below error:

PackageManagement\Get-Package : No match was found for the specified search criteria and module names At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:2216 char:9 + PackageManagement\Get-Package @PSBoundParameters | Microsoft. ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Microsoft.Power...lets.GetPackage:GetPackage) [Get-Pac + FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage

Need to understand why Get-InstalledModule command not giving the expected result.

Upvotes: 2

Views: 3653

Answers (3)

BateTech
BateTech

Reputation: 6526

I just ran into this same issue, and a workaround that worked for me is to use Get-InstalledModule instead.

if(Get-InstalledModule -Name Az -ErrorAction SilentlyContinue)
{
    'Az is installed'
}
else
{
    'Az in NOT installed'
}

Upvotes: 1

Hyndavi
Hyndavi

Reputation: 96

Try with other command available in powershell Get-Module -ListAvailable . This option will display all the installed modules. As you said powershell is working for all the az commands, this option might work for you :)

Upvotes: 1

Vad
Vad

Reputation: 743

Try call this commands

Get-InstalledModule -name "az*"

Az have many modules in pack(also AZ have old version that called "Azure" may be you have it),like:

Az.Accounts
Az.Advisor
Az.Aks
Az.AnalysisServices
Az.ApiManagement
Az.ApplicationInsights
Az.Automation
Az.Batch
Az.Billing
Az.Cdn
Az.CognitiveServices
Az.Compute
Az.ContainerInstance
Az.ContainerRegistry
Az.DataBoxEdge
Az.DataFactory
Az.DataLakeAnalytics
Az.DataLakeStore
Az.DeploymentManager
Az.DevTestLabs
Az.Dns
Az.EventGrid
Az.EventHub
Az.FrontDoor
Az.HDInsight
Az.HealthcareApis
Az.IotHub
Az.KeyVault
Az.LogicApp
Az.MachineLearning
Az.ManagedServices
Az.MarketplaceOrdering
Az.Media
Az.Monitor
Az.Network
Az.NotificationHubs
Az.OperationalInsights
Az.PolicyInsights
Az.PowerBIEmbedded
Az.PrivateDns
Az.RecoveryServices
Az.RedisCache
Az.Relay
Az.Resources
Az.ServiceBus
Az.ServiceFabric
Az.SignalR
Az.Sql
Az.SqlVirtualMachine
Az.Storage
Az.StorageSync
Az.StreamAnalytics
Az.TrafficManager
Az.Websites

Upvotes: 0

Related Questions