Trước khi nhập mô-đun PowerShell tôi (MyModule.psm1)
, tôi đã viết một hàm trong nó:Powershell: Chỉnh sửa một mô-đun đã nhập khẩu
Function T1()
{
Write-Host "T1 is just called" -ForegroundColor red
}
Trong tôi 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 = @()
}
này được nhập khẩu tốt, khi tôi đã sao chép cả hai tệp trong:
C:\Users\fwaheed\Documents\WindowsPowerShell\Modules\MyModule
và tôi có thể chạy T1
trong phiên họp quyền hạn của mình.
Nhưng bây giờ tôi muốn thêm một chức năng mới trong cùng một mô-đun tức là .:
Function T2()
{
Write-Host "Its now T2.." -ForegroundColor red
}
Ngay cả sau khi khởi động lại phiên Powershell của tôi, nó không bao giờ nhận ra T2
, tuy nhiên T1
vẫn còn làm việc.
Làm thế nào tôi có thể chỉnh sửa mô-đun của tôi đã nhập khẩu như rằng những thay đổi có sẵn ngay lập tức ...
Cảm ơn bó ...
'mô-đun nhập khẩu mymodule-force' là không đủ? –
Đã cố gắng đó là tốt, nhưng vô ích .. :( –
Cảm ơn bạn thân ... Chỉ cần loại bỏ các mô-đun, nhập khẩu một lần nữa và thử với "nhập khẩu-mô-đun MyModule-lực lượng" Và nó làm việc bằng cách thêm 4 chức năng hơn .. –