PowerShell命令版本

PowerShell命令版本,powershell,Powershell,Get命令返回版本信息,但这实际上不是命令的版本,而是来自父模块的版本我可以定义与父模块版本不同的函数吗? 根据,没有定义为基于注释的帮助关键字的版本 例如: PS C:\> Get-Command Get-ADUser CommandType Name Version Source ----------- ----

Get命令
返回版本信息,但这实际上不是命令的版本,而是来自父模块的版本我可以定义与父模块版本不同的函数吗?

根据,没有定义为基于注释的帮助关键字的版本

例如:

PS C:\> Get-Command Get-ADUser

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-ADUser                                         1.0.0.0    ActiveDirectory


PS C:\> Get-Command Get-ChildItem

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-ChildItem                                      3.1.0.0    Microsoft.PowerShell.Management


PS C:\> Get-Module Microsoft.PowerShell.Management

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}


PS C:> Get-Command -Module Microsoft.PowerShell.Management | Group-Object Version

Count Name                      Group
----- ----                      -----
   89 3.1.0.0                   {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
我可以定义与父模块版本不同的函数吗?

没有


编辑:

正如Jeroen Mostert所说,您必须创建自己的模块并定义其版本。

函数没有版本,cmdlet有版本。然后只显示其父模块的版本。然后是非动态的模块。如果你真的想这样做,你必须定义一个只包含函数的新模块,然后加载它来隐藏另一个模块的定义。。。对于一个函数来说,这似乎需要花费大量的精力。对于这样的函数,使用
.Notes
就足够了。取决于你的观众