Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing an already imported module

Before importing my powershell module (MyModule.psm1), I have written one function in it:

Function T1() {     Write-Host "T1 is just called" -ForegroundColor red } 

In my MyModule.psd1:

@{     PowerShellVersion = '2.0'     PowerShellHostName = ''     PowerShellHostVersion = '2.0'     RequiredModules = @()     ScriptsToProcess = @()     NestedModules = @()     FunctionsToExport = '*'     CmdletsToExport = '*'     VariablesToExport = '*'     ModuleList = @()     FileList = @() } 

This is imported fine, when I copied both files in:

C:\Users\fwaheed\Documents\WindowsPowerShell\Modules\MyModule

and I'm able to run T1 in my PowerShell session. But now I wanted to add a new function in same module i.e.:

Function T2() {     Write-Host "Its now T2.." -ForegroundColor red } 

Even after restarting my PowerShell session, it never recognize T2, however T1 is still working. How can I edit my already imported module such that changes are available immediately.

like image 635
Farrukh Waheed Avatar asked Sep 27 '13 07:09

Farrukh Waheed


1 Answers

Use the -Force command with the Import-Module and it will reload it.

like image 109
Alex Kwitny Avatar answered Oct 09 '22 08:10

Alex Kwitny