Find any Module via Powershell

Welcome Back to another blog of mine. I was training few of my colleagues on Powershell and one of them asked me following question.

How do you find module if its not already in Powershell???

I said: You can find anything you want if you search correctly.
They said: That’s not very helpful is it, tell us the easy way mate..

I was like grrrrr let me have my moment to feel like a master 😛

That’s when I taught them this small script which basically made all of them to explore Powershell more.

Find-Module 

There is simple thing you need to do before you start finding modules. these are not mandatory but standard practice:
1. Open Powershell.exe or Powershell_ise.exe as an Administrator.
2. Start Finding 😉

They asked me to show how find Exchange Online modules and install it.

Get-Module -ListAvailable

Using the above module you can see what are the available module currently loaded into the memory that you can use without having to install or import.

Now you know the required Module is not there, you will be using the Find-Module Command to search the repository PSGallery

Note: There are 6607 modules in PsGallery (How do I believe this guy? Look at the below snip)

Find Total module in PSGallery
Find-Module ExchangeOnlineManagement
Finding ExchangeOnlineManagement Module via Powershell

They also asked me: That’s cool. What if I don’t know the full name of the module??
I said: That’s a good question let me show you something interesting and showed the below.

Finding Module using wildcard

If you don’t know the full name of the module you always use * after the noun that you are looking for in this scenario I used “Exchange*” meaning Modules that has the name starting with Exchange will come up as a result for you to choose the right one by reading the Description.

Once you find the right one in our case it will the ExchangeOnlineManagment. Let go ahead with Installing the Module and Importing it.

Install-Module -Name ExchangeOnlineManagement -Force -Confirm:$false

Now we know the module name we can run the above command, the 2 switches -Force and -Confirm:$false is to reduce UI interaction and override if the version is already existing in the Computer. If you run without the -Confirm:$false switch you will be prompted to allow the installation of the module.

Once installed you can see the commands that module has using the following command.

Get-Command -Module ExchangeOnlineManagement
Result of above script

Now all you have to do it is connect the Exchange command and start working.

Finding modules are so easy, most of the time you don’t have to open a browser.

Hopefully this is helpful.

Published by iamfazul

Author of the site

One thought on “Find any Module via Powershell

Leave a comment