Reputation: 2043
I'll preface this by saying I am not an expert powershell user by any means, so I'm probably going about this the wrong way.
I have a module that I am working on regularly and I update / tweak it often. It is stored in C:\Users\-user-\Documents\WindowsPowerShell\Modules
if that matters.
Currently I have to close the powershell window and reopen a new one if I want the new / updated methods to be accessible - even when I perform an import in the same window that I am executing commands in.
I have tried doing . $profile
but this does nothing. Do I need to add the module to the profile?
Upvotes: 0
Views: 474
Reputation: 3596
An alternative to removing and adding the module would be simply Import-Module myModule -Force
:
-Force [< SwitchParameter >]
Indicates that this cmdlet re-imports a module and its members, even if the module or its members have an access mode of read-only.
Upvotes: 2
Reputation: 1398
You can simply unload the module and then load it again.
As we can see in Microsoft's documentation:
Remove-Module
The Remove-Module cmdlet removes the members of a module, such as cmdlets and functions, from the current session.
Import-Module
The Import-Module cmdlet adds one or more modules to the current session. The modules that you import must be installed on the local computer or a remote computer.
Here's a code for example:
# Unload the Module
PS > Remove-Module myModule -Force
# Load it again
PS > Import-Module myModule
Upvotes: 1