PowerShellGet Introduction

With PowerShell version 5 Microsoft released a way of installing modules using PowerShell. Before v5 you would have to copy modules into specific folders where the module folder name has to be exactly has the module .psd1 file. Getting it right for someone who wasn’t writing modules was hard. I know at work I would simply copy the files for them into C:WindowsSystem32WindowsPowerShellv1.0Modules so the modules could be loaded in the user’s session.

Those days are thankfully gone. PowerShellGet works off of the NuGet package management framework devised for Visual Studio and allows anyone to install Modules with ease. Shipping currently in the latest v5 version users can install modules with the following command:

Find-Module -Name Powershellcookbook | Install-Module -Verbose

You’ll notice that by default PowerShell does not trust the repository in which you are downloading from. PowerShell ships with a module gallery populated with modules from the community. These are not modules vetted by Microsoft but some modules do come from Microsoft employees. The PowerShellCookbook module happens to be written by Lee Holmes, a Microsoft employee who works on Windows Server. Other modules are written by Microsoft MVPs and other respectable leaders in the community. There is a chance that the content you download could be malicious. Always inspect any module you download from any unverified source.

In order to checkout repository information run Get-PSRepository.

Get-PSRepository | format-list *

Notice how the InstallationPolicy property is set to untrusted. You should keep it untrusted since you don’t know who is actually posting the module. In the future you may stand up your own NuGet repository where you vet all published content. Then, you can set your repository to trusted to bypass any confirmations.

Running Install-Module again and excepting the confirmation means that you now have the module installed. Running Get-InstalledModule reveals a list of Modules you’ve installed from Install-Module.

Version Name Repository Description 
------- ---- ---------- ----------- 
1.3.2 PowerShellCookbook PSGallery Sample scripts from the Windows PowerShell Cookbook

To confirm we actually have PowerShellCookbook installed we run on of the cmdlets named Show-Object.

Get-Process -name Powershell | Show-Object

Show-Object is useful for exploring new object types. You can drill into the objects and their properties in a visual way to see exactly what is in them.

When new versions of modules come out you simply have to run Update-Module to get the latest version.


Be sure to check out the other commands inside of PowerShellGet.

get-command -Module powershellget