No Match Was Found For The Specified Search Criteria And Module Name

Introduction

When you are getting this error “No Match was found for the specified search criteria and module name ‘PSLogging’. Try Get-PSRepository to see all available registered module repositories.

No Match was found for the specified search criteria and module name

Cause

This could be due to the required module in the script is not available for the user session or the required module is not loaded during the script execution and hence some of the functions dependent on the module will fail to run. Also in some cases the windows machines are in a much more secure environment. In order to install the required modules it may not be able to communicate with PowerShell Gallery (https://www.PowerShellGallery.com). In such cases, it is required to install the required PS modules in offline mode.

Steps to Fix the problem

To fix this kind of PS module issues, you can do the following steps. These steps worked for me.

Step 1

Download the raw nupkg (nuget package file) into the custom folder. I called here it as C:\Install. The nuget package file can be downloaded from the PS gallery repository. In my case, the file can be downloaded from the location https://www.powershellgallery.com/packages/PSLogging/2.5.2

No Match was found for the specified search criteria and module name

Step 2

After downloading the file, open the PowerShell ISE as administrator and in the command window enter the following commands. The following command installs the package provider called ‘NuGet’. In the below screenshot, the ISE is opened as ‘Administrator’ and in the command prompt run the command (whoami) to get the current context.

No Match was found for the specified search criteria and module name

Install-PackageProvider -Name NuGet

Step 3

Register the Local PowerShell repository where the NuGet file is downloaded as ‘Trusted’.

Register-PSRepository -Name local -SourceLocation C:\install -InstallationPolicy Trusted

Step 4

Now run the install module command to install the module from the PowerShell repository.

Install-Module -Name PSLogging -Scope AllUsers

No Match was found for the specified search criteria and module name

Note
You may get the warning ‘Unable to resolve package source ‘https://www.powershellgallery.com/api/v2’ which is fine. Also, since you ran the command scoped to ‘AllUsers’, users who ever logged into this system should be able to use this module by running Import-Module command.

Validation

Try running PS ISE Module as different user and run the following command to get the available PS modules that are imported.

Get-Module

If you are unable to find the module (which is in this case PSLogging), try running command Import-Module first and then Get-Module.

Import-Module PSLogging
Get-Module

References


Similar Articles