New-ModuleManifest
创建新的模块清单。
New-ModuleManifest
[-Path] <string>
[-NestedModules <Object[]>]
[-Guid <guid>]
[-Author <string>]
[-CompanyName <string>]
[-Copyright <string>]
[-RootModule <string>]
[-ModuleVersion <version>]
[-Description <string>]
[-ProcessorArchitecture <ProcessorArchitecture>]
[-PowerShellVersion <version>]
[-ClrVersion <version>]
[-DotNetFrameworkVersion <version>]
[-PowerShellHostName <string>]
[-PowerShellHostVersion <version>]
[-RequiredModules <Object[]>]
[-TypesToProcess <string[]>]
[-FormatsToProcess <string[]>]
[-ScriptsToProcess <string[]>]
[-RequiredAssemblies <string[]>]
[-FileList <string[]>]
[-ModuleList <Object[]>]
[-FunctionsToExport <string[]>]
[-AliasesToExport <string[]>]
[-VariablesToExport <string[]>]
[-CmdletsToExport <string[]>]
[-DscResourcesToExport <string[]>]
[-CompatiblePSEditions <string[]>]
[-PrivateData <Object>]
[-Tags <string[]>]
[-ProjectUri <uri>]
[-LicenseUri <uri>]
[-IconUri <uri>]
[-ReleaseNotes <string>]
[-HelpInfoUri <string>]
[-PassThru]
[-DefaultCommandPrefix <string>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-ModuleManifest
cmdlet 将创建新的模块清单(.psd1
)文件,填充其值,并将清单文件保存在指定的路径中。
模块作者可以使用此 cmdlet 为其模块创建清单。 模块清单是包含哈希表的 .psd1
文件。 哈希表中的键和值描述了模块的内容和属性,定义先决条件,并确定组件的处理方式。 模块不需要清单。
New-ModuleManifest
创建包含所有常用清单键的清单,以便可以将默认输出用作清单模板。 若要添加或更改值,或添加此 cmdlet 未添加的模块键,请在文本编辑器中打开生成的文件。
每个参数(Path 和 PassThru除外)都会创建模块清单密钥及其值。
在模块清单中,只需要 ModuleVersion 密钥。 除非在参数说明中指定,否则如果省略命令中的参数,New-ModuleManifest
为无效的关联值创建注释字符串。
在 PowerShell 2.0 中,除了必需的参数值外,New-ModuleManifest
还会提示输入命令中未指定的常用参数的值。 从 PowerShell 3.0 开始,仅当未指定所需的参数值时,New-ModuleManifest
提示。
如果计划在 PowerShell 库中发布模块,清单必须包含某些属性的值。 有关详细信息,请参阅库文档中 发布到 PowerShell 库 的项所需的元数据。
此示例在由 Path 参数指定的文件中创建新的模块清单。 PassThru 参数将输出发送到管道和文件。
输出显示清单中所有键的默认值。
New-ModuleManifest -Path C:\ps-test\Test-Module\Test-Module.psd1 -PassThru
#
# Module manifest for module 'Test-Module'
#
# Generated by: ContosoAdmin
#
# Generated on: 1/22/2019
#
@{
# Script module or binary module file associated with this manifest.
# RootModule = ''
# Version number of this module.
ModuleVersion = '1.0'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = '47179120-0bcb-4f14-8d80-f4560107f85c'
# Author of this module
Author = 'ContosoAdmin'
# Company or vendor of this module
CompanyName = 'Unknown'
# Copyright statement for this module
Copyright = '(c) 2019 ContosoAdmin. All rights reserved.'
# Description of the functionality provided by this module
# Description = ''
# Minimum version of the Windows PowerShell engine required by this module
# PowerShellVersion = ''
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}
此示例创建新的模块清单。 它使用 PowerShellVersion 和 AliasesToExport 参数将值添加到相应的清单键。
$moduleSettings = @{
PowerShellVersion = 1.0
Path = 'C:\ps-test\ManifestTest.psd1'
AliasesToExport = @(
'JKBC'
'DRC'
'TAC'
)
}
New-ModuleManifest @moduleSettings
此示例使用字符串格式指定 BitsTransfer 模块的名称和哈希表格式来指定名称、GUID以及 PSScheduledJob 模块的版本。
$moduleSettings = @{
RequiredModules = ("BitsTransfer", @{
ModuleName="PSScheduledJob"
ModuleVersion="1.0.0.0";
GUID="50cdb55f-5ab7-489f-9e94-4ec21ff51e59"
})
Path = 'C:\ps-test\ManifestTest.psd1'
}
New-ModuleManifest @moduleSettings
此示例演示如何使用 ModuleList、RequiredModules和 NestedModules 参数的字符串和哈希表格式。 可以在同一参数值中合并字符串和哈希表。
此示例使用 HelpInfoUri 参数在模块清单中创建 HelpInfoUri 键。 参数和键的值必须以 http 或 https开头。 此值告知可更新帮助系统在何处查找模块的 HelpInfo XML 可更新帮助信息文件。
$moduleSettings = @{
HelpInfoUri = 'http://https://go.microsoft.com/fwlink/?LinkID=603'
Path = 'C:\ps-test\ManifestTest.psd1'
}
New-ModuleManifest @moduleSettings
有关可更新帮助的信息,请参阅 about_Updatable_Help。 有关 HelpInfo XML 文件的信息,请参阅 支持可更新的帮助。
此示例演示如何获取模块的配置值。 模块清单中的值反映在模块对象的属性值中。
Get-Module
cmdlet 用于使用 List 参数获取 Microsoft.PowerShell.Diagnostics 模块。 该命令将模块发送到 Format-List
cmdlet 以显示模块对象的所有属性和值。
Get-Module Microsoft.PowerShell.Diagnostics -List | Format-List -Property *
LogPipelineExecutionDetails : False
Name : Microsoft.PowerShell.Diagnostics
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Diagnostics\Micro
soft.PowerShell.Diagnostics.psd1
Definition :
Description :
Guid : ca046f10-ca64-4740-8ff9-2565dba61a4f
HelpInfoUri : https://go.microsoft.com/fwlink/?LinkID=210596
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Diagnostics
PrivateData :
Version : 3.0.0.0
ModuleType : Manifest
Author : Microsoft Corporation
AccessMode : ReadWrite
ClrVersion : 4.0
CompanyName : Microsoft Corporation
Copyright : Microsoft Corporation. All rights reserved.
DotNetFrameworkVersion :
ExportedFunctions : {}
ExportedCmdlets : {[Get-WinEvent, Get-WinEvent], [Get-Counter, Get-Counter], [Import-Counter,
Import-Counter], [Export-Counter, Export-Counter]...}
ExportedCommands : {[Get-WinEvent, Get-WinEvent], [Get-Counter, Get-Counter], [Import-Counter,
Import-Counter], [Export-Counter, Export-Counter]...}
FileList : {}
ModuleList : {}
NestedModules : {}
PowerShellHostName :
PowerShellHostVersion :
PowerShellVersion : 3.0
ProcessorArchitecture : None
Scripts : {}
RequiredAssemblies : {}
RequiredModules : {}
RootModule :
ExportedVariables : {}
ExportedAliases : {}
ExportedWorkflows : {}
SessionState :
OnRemove :
ExportedFormatFiles : {C:\Windows\system32\WindowsPowerShell\v1.0\Event.format.ps1xml,
C:\Windows\system32\WindowsPowerShell\v1.0\Diagnostics.format.ps1xml}
ExportedTypeFiles : {C:\Windows\system32\WindowsPowerShell\v1.0\GetEvent.types.ps1xml}
指定模块导出的别名。 允许通配符。
可以使用此参数来限制模块导出的别名。 它可以从导出的别名列表中删除别名,但无法向列表中添加别名。
如果省略此参数,New-ModuleManifest
创建 AliasesToExport 键,其值为 *
(all),这意味着模块中定义的所有别名都由清单导出。
类型: | String[] |
Position: | Named |
默认值: | * (all) |
必需: | False |
接受管道输入: | False |
接受通配符: | True |
指定模块作者。
如果省略此参数,New-ModuleManifest
使用当前用户的名称创建 Author 键。
类型: | String |
Position: | Named |
默认值: | Name of the current user |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块所需的Microsoft .NET Framework 公共语言运行时(CLR)的最低版本。
备注
此设置仅适用于 PowerShell Desktop 版本,例如 Windows PowerShell 5.1,仅适用于低于 4.5 的 .NET Framework 版本。 此要求对较新版本的 PowerShell 或 .NET Framework 不起作用。
类型: | Version |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块导出的 cmdlet。 允许通配符。
可以使用此参数来限制模块导出的 cmdlet。 它可以从导出的 cmdlet 列表中删除 cmdlet,但无法将 cmdlet 添加到列表中。
如果省略此参数,New-ModuleManifest
创建 CmdletsToExport 键,其值为 *
(all),这意味着模块中定义的所有 cmdlet 都由清单导出。
类型: | String[] |
Position: | Named |
默认值: | * (all) |
必需: | False |
接受管道输入: | False |
接受通配符: | True |
标识创建模块的公司或供应商。
如果省略此参数,New-ModuleManifest
创建值为“Unknown”的 CompanyName 键。
类型: | String |
Position: | Named |
默认值: | "Unknown" |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块的兼容 PSEditions。 有关 PSEdition 的信息,请参阅 模块与兼容的 PowerShell Editions。
类型: | String[] |
接受的值: | Desktop, Core |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
在运行 cmdlet 之前,提示你进行确认。
类型: | SwitchParameter |
别名: | cf |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块的版权声明。
如果省略此参数,New-ModuleManifest
会创建一个 版权 键,其值为 (c) <year> <username>. All rights reserved.
,其中 <year>
是当前年份,<username>
是 Author 键的值。
类型: | String |
Position: | Named |
默认值: | (c) <year> <username>. All rights reserved. |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定在模块中导入到会话时所有命令的名词前面附加的前缀。 输入前缀字符串。 前缀可防止用户会话中的命令名称冲突。
模块用户可以通过指定 Import-Module
cmdlet 的 Prefix 参数来替代此前缀。
此参数是在 PowerShell 3.0 中引入的。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
描述模块的内容。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块所需的Microsoft .NET Framework 的最低版本。
备注
此设置仅适用于 PowerShell Desktop 版本,例如 Windows PowerShell 5.1,仅适用于低于 4.5 的 .NET Framework 版本。 此要求对较新版本的 PowerShell 或 .NET Framework 不起作用。
类型: | Version |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块导出的 Desired State Configuration (DSC) 资源。 允许通配符。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | True |
指定模块中包含的所有项。
此密钥旨在充当模块清单。 发布模块时,将包含密钥中列出的文件,但不会自动导出任何函数。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定导入模块时运行的格式设置文件(.ps1xml
)。
导入模块时,PowerShell 使用指定的文件运行 Update-FormatData
cmdlet。
由于格式设置文件的范围不一定,因此它们会影响会话中的所有会话状态。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块导出的函数。 允许通配符。
可以使用此参数来限制模块导出的函数。 它可以从导出的别名列表中删除函数,但无法将函数添加到列表中。
如果省略此参数,New-ModuleManifest
会创建一个 FunctionsToExport 键,其值为 *
(all),这意味着模块中定义的所有函数都由清单导出。
类型: | String[] |
Position: | Named |
默认值: | * (all) |
必需: | False |
接受管道输入: | False |
接受通配符: | True |
指定模块的唯一标识符。 GUID 可用于区分同名模块。
如果省略此参数,New-ModuleManifest
会在清单中创建 GUID 键,并为值生成 GUID。
若要在 PowerShell 中创建新的 GUID,请键入 [guid]::NewGuid()
。
类型: | Guid |
Position: | Named |
默认值: | A GUID generated for the module |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块的 HelpInfo XML 文件的 Internet 地址。 输入以 http 或https开头的统一资源标识符(URI)。
HelpInfo XML 文件支持 PowerShell 3.0 中引入的可更新帮助功能。 它包含有关模块可下载帮助文件的位置以及每个受支持区域设置的最新帮助文件的版本号的信息。
有关可更新帮助的信息,请参阅 about_Updatable_Help。 有关 HelpInfo XML 文件的信息,请参阅 支持可更新的帮助。
此参数是在 PowerShell 3.0 中引入的。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块图标的 URL。 指定的图标显示在模块的库网页上。
类型: | Uri |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块许可条款的 URL。
类型: | Uri |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
列出此模块中包含的所有模块。
输入每个模块名称作为字符串或具有 ModuleName 和 ModuleVersion 键的哈希表。 哈希表还可以具有可选的 GUID 键。 可以在参数值中合并字符串和哈希表。
此密钥旨在充当模块清单。 不会自动处理此键值中列出的模块。
类型: | Object[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块的版本。
此参数不是必需的,但清单中需要 ModuleVersion 密钥。 如果省略此参数,New-ModuleManifest
创建值为 1.0 的 ModuleVersion 键。
类型: | Version |
Position: | Named |
默认值: | 1.0 |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定导入模块会话状态的脚本模块(.psm1
)和二进制模块(.dll
)。
NestedModules 中的文件 键按值中列出的顺序运行。
输入每个模块名称作为字符串或具有 ModuleName 和 ModuleVersion 键的哈希表。 哈希表还可以具有可选的 GUID 键。 可以在参数值中合并字符串和哈希表。
通常,嵌套模块包含根模块对其内部处理所需的命令。
默认情况下,嵌套模块中的命令将从模块的会话状态导出到调用方会话状态,但根模块可以限制其导出的命令。 例如,使用 Export-ModuleMember
命令。
模块会话状态中的嵌套模块对根模块可用,但它们不会由调用方会话状态中的 Get-Module
命令返回。
NestedModules 键中列出的脚本(.ps1
)在模块的会话状态中运行,而不是在调用方会话状态中运行。 若要在调用方会话状态下运行脚本,请在清单中 ScriptsToProcess 键的值中列出脚本文件名。
类型: | Object[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
将生成的模块清单写入控制台并创建 .psd1
文件。 默认情况下,此 cmdlet 不会生成任何输出。
类型: | SwitchParameter |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定新模块清单的路径和文件名。 输入具有 .psd1
文件扩展名的路径和文件名,例如 $pshome\Modules\MyModule\MyModule.psd1
。
Path 参数是必需的。
如果指定现有文件的路径,New-ModuleManifest
将替换该文件而不发出警告,除非该文件具有只读属性。
清单应位于模块的目录中,清单文件名应与模块目录名称相同,但文件扩展名为 .psd1
。
备注
不能使用变量(如 $PSHOME
或 $HOME
),以响应 Path 参数值的提示。 若要使用变量,请在命令中包含 Path 参数。
类型: | String |
Position: | 1 |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
指定模块所需的 PowerShell 主机程序的名称。 输入主机程序的名称,例如 Windows PowerShell ISE 主机 或 ConsoleHost。 不允许通配符。
若要查找主机程序的名称,请在程序中键入 $Host.Name
。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定适用于该模块的 PowerShell 主机程序的最低版本。 输入版本号,例如 1.1。
类型: | Version |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定适用于此模块的 PowerShell 的最低版本。 例如,可以输入 1.0、2.0 或 3.0 作为参数的值。 它必须采用 X.X 格式。 例如,如果提交 5
,PowerShell 将引发错误。
类型: | Version |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定导入模块时传递给模块的数据。
类型: | Object |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块所需的处理器体系结构。 有效值为 x86、AMD64、IA64、MSIL 和 None(未知或未指定)。
类型: | ProcessorArchitecture |
接受的值: | None, MSIL, X86, IA64, Amd64, Arm |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定有关此项目的网页的 URL。
类型: | Uri |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定发行说明。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块所需的程序集 (.dll
) 文件。 输入程序集文件名。
PowerShell 在更新类型或格式、导入嵌套模块或导入在 RootModule 键的值中指定的模块文件之前加载指定的程序集。
使用此参数列出模块所需的所有程序集,包括必须加载的程序集以更新 FormatsToProcess 或 TypesToProcess 键中列出的任何格式或类型文件,即使这些程序集也作为二进制模块列在 NestedModules 键中。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定必须处于全局会话状态的模块。 如果所需的模块未处于全局会话状态,PowerShell 会导入它们。 如果所需的模块不可用,Import-Module
命令将失败。
输入每个模块名称作为字符串或具有 ModuleName 和 ModuleVersion 键的哈希表。 哈希表还可以具有可选的 GUID 键。 可以在参数值中合并字符串和哈希表。
在 PowerShell 2.0 中,Import-Module
不会自动导入所需的模块。 它只是验证所需的模块是否处于全局会话状态。
类型: | Object[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块的主文件或根文件。 输入脚本(.ps1
)、脚本模块(.psm1
)、模块清单(.psd1
)、程序集(.dll
)、cmdlet 定义 XML 文件(.cdxml
)或工作流(.xaml
)。 导入模块后,从根模块文件导出的成员将导入调用方会话状态。
如果模块具有清单文件,并且未在 RootModule 键中指定根文件,则清单将成为模块的主文件,模块将成为清单模块(ModuleType = Manifest)。
若要从具有清单的模块中的 .psm1
或 .dll
文件中导出成员,必须在清单中的 RootModule 或 NestedModules 键的值中指定这些文件的名称。 否则,不会导出其成员。
备注
在 PowerShell 2.0 中,此密钥称为 moduleToProcess 。 可以使用 RootModule 参数名称或其 ModuleToProcess 别名。
类型: | String |
别名: | ModuleToProcess |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定导入模块时在调用方会话状态中运行的脚本 (.ps1
) 文件。
可以使用这些脚本来准备环境,就像使用登录脚本一样。
若要指定在模块的会话状态中运行的脚本,请使用 NestedModules 键。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定标记数组。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定导入模块时运行的类型文件(.ps1xml
)。
导入模块时,PowerShell 使用指定的文件运行 Update-TypeData
cmdlet。
由于类型文件没有限定范围,因此它们会影响会话中的所有会话状态。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
指定模块导出的变量。 允许通配符。
可以使用此参数来限制模块导出的变量。 它可以从导出的变量列表中删除变量,但不能将变量添加到列表中。
如果省略此参数,New-ModuleManifest
创建一个 VariablesToExport 键,其值为 *
(all),这意味着模块中定义的所有变量都由清单导出。
类型: | String[] |
Position: | Named |
默认值: | * (all) |
必需: | False |
接受管道输入: | False |
接受通配符: | True |
显示 New-ModuleManifest
运行时会发生什么情况。 该 cmdlet 未运行。
类型: | SwitchParameter |
别名: | wi |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
None
不能通过管道将对象传递给此 cmdlet。
None
默认情况下,此 cmdlet 不返回任何输出。
使用 PassThru 参数时,此 cmdlet 返回表示模块清单的字符串。
New-ModuleManifest
创建编码为 UTF16 的模块清单(.psd1
) 文件。
模块清单通常是可选的。 但是,导出全局程序集缓存中安装的程序集需要模块清单。
若要在 $pshome\Modules
目录中添加或更改文件,请使用 以管理员身份运行 选项启动 PowerShell。
在 PowerShell 2.0 中,尽管模块清单中不需要 New-ModuleManifest
的许多参数都是必需的。 从 PowerShell 3.0 开始,只有 Path 参数是必需的。
会话是 PowerShell 执行环境的实例。 会话可以有一个或多个会话状态。 默认情况下,会话只有全局会话状态,但每个导入的模块都有自己的会话状态。 会话状态允许模块中的命令在不影响全局会话状态的情况下运行。
调用方会话状态是将模块导入到的会话状态。 通常,它是指全局会话状态,但当模块导入嵌套模块时,调用方是模块,调用方会话状态是模块的会话状态。