Windows PowerShell与服务器管理操作指南
一、高级Windows PowerShell技巧:为函数添加帮助信息
(一)为函数添加基于注释的帮助
- 打开文件:在Windows PowerShell ISE窗口中,打开之前创建的
MyAppEvent.psm1文件。 - 添加注释帮助:在脚本中输入以下内容,可能只需添加加粗部分,然后点击“保存并退出”。
function Get-AppEvents { <# .SYNOPSIS Get-AppEvents retrieves the newest 100 events from the Application event log, groups and sorts them by InstanceID and then displays only top 5 events that have occured the most. .DESCRIPTION See the synopsis section. .EXAMPLE To run the function, simply invoke it: PS> Get-AppEvents #> Get-EventLog –LogName Application –Newest 100|Group-Object - Property InstanceId|Sort-Object –Descending -Property