June 19th, 2014

PowerTip: Unload All Non-Microsoft Modules

Doctor Scripto
Scripter

Summary: Learn to unload all non-Microsoft Windows PowerShell modules.

Hey, Scripting Guy! Question Windows PowerShell is acting funny and I want to unload all modules that are not written by Microsoft.
          How can I easily do this?

Hey, Scripting Guy! Answer Use Get-Module to find all loaded modules, use the Where-Object cmdlet to filter for authors
          that do not match Microsoft, and then pipe the results to the Remove-Module cmdlet:

Get-Module | where Author -notmatch 'microsoft' | Remove-Module

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.