Get-Command
返回版本信息,但实际上这不是命令的版本,而是父模块的版本。我能定义一个与父模块不同版本的函数吗?
根据Microsoft文档,没有将version定义为基于注释的关键字。示例:
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...}
.Notes
来处理这样的事情。取决于你的受众。 - Matt