How do I force powershell to reload a custom module?

Try the following:

Import-Module 'E:\xxx.ps1' -Force

From what I've gathered. Import-Module does not import classes. You have to use the "using module " and it has to be in the first line of your script. On top of that problem, the classes appear to be "cached" in some esoteric way that precludes any uninstall-module or remove-module options. I've found I basically need to restart my powershell terminal to clear it.

If classes are not involved use import-module OR install-module. In both cases you can do a get-modules -all or get-installedmodule and then remove-module or uninstall-module. You want to make sure you look for all versions and pipe that to remove/uninstall to ensure you wipe everything out.


As suggested by wOxxOm, you can try pass the -Force flag:

Import-Module ... -Force

Or if that does not work try to explicitly remove it and then reimport with:

Remove-Module

For anyone else coming across this issue, see https://github.com/PowerShell/PowerShell/issues/2505

It seems that there is a known long-standing bug regarding importing of modules that are anything above rudimentary level in complexity (for example, I have a module with a single class and class method that fails to update).