Przed importem mój moduł powershell (MyModule.psm1)
, napisałem jedną funkcję w nim:PowerShell: Edycja już importowanego modułu
Function T1()
{
Write-Host "T1 is just called" -ForegroundColor red
}
W moim MyModule.psd1
:
@{
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '2.0'
# Name of the Windows PowerShell host required by this module
PowerShellHostName = ''
# Minimum version of the Windows PowerShell host required by this module
PowerShellHostVersion = '2.0'
# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module
ScriptsToProcess = @()
# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = @()
# Functions to export from this module
FunctionsToExport = '*'
# Cmdlets to export from this module
CmdletsToExport = '*'
# Variables to export from this module
VariablesToExport = '*'
# List of all modules packaged with this module
ModuleList = @()
# List of all files packaged with this module
FileList = @()
}
ten jest importowany w porządku, kiedy skopiowano oba pliki w:
C:\Users\fwaheed\Documents\WindowsPowerShell\Modules\MyModule
i mogę uruchomić T1
w mojej sesji PowerShell.
Ale teraz chciałem dodać nową funkcję w sam moduł tj .:
Function T2()
{
Write-Host "Its now T2.." -ForegroundColor red
}
Nawet po ponownym uruchomieniu moją sesję PowerShell, nigdy nie uznają T2
jednak T1
nadal pracuje.
Jak mogę edytować już importowany moduł taki, że zmiany są natychmiast dostępne ...
Dzięki kilka ...
'moduł-import modułu -modułu 'to za mało? –
Próbowałem również, ale na próżno .. :( –
Dzięki, kolego ... Po prostu usunięto moduł, Zaimportowano ponownie i wypróbowałem z "moduł importu modułu MyModule" I działało przez dodanie 4 dodatkowych funkcji .. –