gpt4 book ai didi

powershell - 为嵌套的 PowerShell 模块创建 list

转载 作者:行者123 更新时间:2023-12-04 15:00:30 25 4
gpt4 key购买 nike

我对嵌套的 PowerShell 模块有一个小问题。
Get-Module正确识别 ExportedCommands ,但 ModuleType被列为 Script ,而不是 Manifest :

PS>get-module

ModuleType Name ExportedCommands
---------- ---- ----------------
Script Bar Get-Bar
Script Foo Get-Foo

目录结构:
|-Modules
|-Foobar
|-Foobar.psd1
|-Bar
|-Bar.psm1
|-Foo
|-Foo.psm1

Foobar.psd1:
...
# Script module or binary module file associated with this manifest
ModuleToProcess = ''

# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = 'Foo\Foo.psm1', 'Bar\Bar.psm1'
...

我是否正确构建了 PSD1 文件?在我的情况下,我是否需要一个虚拟/空的 Foobar.psm1 文件(在 PSD1 文件中有相应的条目)?我需要嵌套的目录结构,还是可以只在父目录 (Foobar) 中包含两个 PSM1 文件(bar.psm1 和 foo.psm1)?

最佳答案

目录结构需要是:

|-Modules
|-Foobar
|-Foobar.psd1
|-Bar.psm1
|-Foo.psm1

Foobar.psd1 需要:
...
# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = 'Foo.psm1', 'Bar.psm1'
...

关于powershell - 为嵌套的 PowerShell 模块创建 list ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16424171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com