Managing tasks in PowerShell often feels like magic—until you need missing functionality. Whether automating updates, managing user accounts, or accessing advanced features, you’ll quickly find that the built-in tools don’t cover everything. In such cases, you realize: I need more modules, but where do I even start?
By the end of this guide, you’ll have the skills to automate more tasks and keep your environment lean and efficient.
Dive in and become a PowerShell module pro!
Searching for a Module in the PowerShell Gallery
Managing tasks in PowerShell often requires modules that aren’t built-in, so you’ll need to search for them. For example, if you’re managing Windows updates or automating complex tasks, the default PowerShell installation might not include the necessary tools.
If you’re unsure about the exact module name, start by using a wildcard search with Find-Module
:
Find-Module '*windowsupdate*'
This command lists modules matching the wildcard pattern.
Once you locate the desired module, refine the search by specifying the module name (i.e., PSWindowsUpdate
):
Find-Module -Name 'PSWindowsUpdate'
Installing a Module
Finding a module is just the first step; the next is getting it onto your system. Modules in the PowerShell Gallery are like apps in an app store. You can quickly download and install them once you know what you’re looking for.
Download the module directly by piping the output of Find-Module
to Install-Module
:
Find-Module -Name 'PSWindowsUpdate' | Install-Module
If you see a prompt about an untrusted repository, the reason is that PowerShell requires explicit confirmation. This behavior happens when downloading from repositories with an Untrusted
installation policy.
To avoid repeated prompts, you can set the repository policy to Trusted
:
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Re-run the install command:
Find-Module -Name 'PSWindowsUpdate' | Install-Module
Verifying the Installed Module
After installing a module, you’ll want to ensure it’s ready to use. However, that module might not install where you expect or require additional verification before use.
For instance, the PSWindowsUpdate
module is installed on your user profile by default. If so, confirming its location before trying to execute its commands is critical.
To confirm where PowerShell installed the module, use:
Get-Module -Name PSWindowsUpdate -ListAvailable | Select-Object ModuleBase
This command returns the location of the module on the filesystem. By default, modules are installed in your user profile’s Documents folder.
To list all available commands within the module:
Get-Command -Module PSWindowsUpdate
Uninstalling a Module
Even the most valuable modules won’t be needed forever, like the PSWindowsUpdate
module. After using this module to complete a script or manage updates, you may want to remove it to keep your system tidy or prevent unnecessary resource usage.
To remove a specific module:
Uninstall-Module -Name PSWindowsUpdate
If the module is currently in use, PowerShell might prevent you from uninstalling it.
Check if the module is loaded:
Get-Module PSWindowsUpdate
If loaded, unload it:
Remove-Module PSWindowsUpdate
Now, re-attempt the uninstall:
Uninstall-Module -Name PSWindowsUpdate
If the issue persists, close the current PowerShell session, reopen it and run the uninstall command again.
Conclusion
Throughout this tutorial, you learned how to manage PowerShell modules effectively by leveraging the PowerShell Gallery. We began by searching for modules and moved on to installing them and uninstalling unwanted ones. You also encountered practical scenarios, such as resolving untrusted repository prompts and unloading active modules.
With these skills, you’re equipped to explore other modules in the PowerShell Gallery to enhance automation and solve challenges in your environment. For example, consider modules for managing Active Directory or Azure, or even experiment with creating custom modules to share with others.
By mastering module management, you unlock PowerShell’s full potential, enabling it to adapt to your unique administrative needs.