Installing A Module From The PowerShell Gallery

My motto is not to rebuild the wheel. Not that I physically could build a wheel but metaphorically speaking, I suppose. Anyway, oh yeah, I thought of that because of the PowerShell Gallery! What does this have to do with the other? The PowerShell Gallery allows you to download other modules already built! No need to build your own. Josh was so kind in this video to show us how to make it happen.

In this snip, we're going to look at installing powershell modules from the powerShell Gallery to get started run PowerShell as an administrator. And then if you know the name of the module you're looking to install you can run install module and specify the name. I use Posh RS job in a lot of my scripts, so I'll go ahead and install that. If this is the first time you're running install module you'll be prompted to install the required nu get provider I’ll press why to confirm that I want that done. And then because PowerShell Gallery is considered an untrusted repository because anyone can upload anything to it. I need to confirm that I'm happy for this module to be installed from it, I'll type Y to confirm that I'm happy. And then the modules installed I can confirm that by running get module. Specifying the name. And including list available. I have to include list available because it's not get loaded into my powershell session. Then I can see it's been installed. And that's been installed to my program files directory. If I'm not 100% sure of the name of the module. I want to install I can first use find module. To search for for example, I know that VM Ware’s for example, I know that VM Ware's uploaded their power. CLI module to the gallery. But I'm not 100% sure on whether or not the prefix. The name or not so I can use wildcards and looked for power CLI with the wild card at the front of the name to account for any prefixes. This will then go off and searched the powerShell Gallery and will return any results. It's found a module named VM Ware dot power CLI and now I can pipe that result to install module. Again, I must confirm whether or not. I want to install from a untrusted repository press Y to confirm. As you can see the power CLI module has a number of Dependencies and these are being handled for you automatically. And Unfortunately once you've got to the end of the installation for power CLI you’re told that there are commands in it, that already exist on your system is could be that other modules are using the same names as the one that you're trying to install so in order to actually install this module. I then have to rerun the install command and specify allow clobber which tells powershell that I'm OK with these 2 modules, having overlapping function names. And now that modules was successfully installed we can again confirm by running get module specifying a name. And I'm going to look for all VM Ware modules and list available. As you can see power CLI has been installed along with all of the other VM ware dependencies that relies on. Finally, it's also possible to install modules to your user directory and to do so. You don't need to run powershell as an administrator to show this, or running non elevated copy of powershell. And all install import Excel and or specify a scope. Of current user or confirm that I want this to be installed from the Untrusted repository. That module is being installed, and we can see where we're running get module and as you can see it's been installed to my local user directory. That's been installing powershell modules from the powerShell Gallery. Thank you for watching.