如何使用 PowerShell 幫助命令?
要獲取特定命令的幫助,可以使用 **Get-Help(別名:help)** cmdlet 以及您需要幫助的命令。
例如,
help Get-Service
執行此命令後,您將獲得 **名稱、概要、語法、描述、相關連結和備註** 的說明。
支援幫助的多個引數如下所示
**-Full** - 包含引數說明和示例的詳細幫助。
help Get-Service -Full
**-Detailed** - 引數的詳細幫助,不包含示例。
help Get-Service -Detailed
**-Examples** - 僅在 PowerShell 螢幕上顯示與示例相關的幫助。
help Get-Service -Examples
**-Online** - 將在 Microsoft 網站上線上搜尋 cmdlet 的幫助內容。
help Get-Service -Online
當您安裝或更新 PowerShell 版本或安裝預裝 PowerShell 的新作業系統時,您需要確保從 Microsoft 網站更新幫助內容,這建議每月進行一次,因為某些幫助內容會過時,並且 MS 會持續更新其幫助內容。
如果過時的幫助駐留在您的系統中,則某些 cmdlet 的幫助不可見,此時您需要更新幫助內容。
當指定 **-ShowWindow** 引數時,將為該特定命令在單獨的視窗中顯示幫助。例如,
help Get-Service -ShowWindow
在這裡,“設定”按鈕中有一些選項可以篩選出特定專案。
如果您需要任何特定部分相關的幫助,請選擇該設定。
如果您需要命令列中引數的幫助,則使用 -Parameter 和命令名稱。例如,
help Get-Service -Parameter ComputerName
PS C:\Users\Chirag.Nagarekar> help Get-Service -Parameter ComputerName -ComputerName <System.String[]> Gets the services running on the specified computers. The default is the local computer. Type the NetBIOS name, an IP address, or a fully qualified domain name (FQDN) of a remote computer. To specify the local computer, type the computer name, a dot (.), or localhost. This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of Get-Service even if your computer is not configured to run remote commands. Required? false Position? named Default value None Accept pipeline input? True (ByPropertyName) Accept wildcard characters? false
如果您需要顯示所有引數,則使用 * 代替引數名稱。
help Get-Service -Parameter *
同樣,如果您需要命令列中僅與示例部分相關的幫助,則在命令中使用 -Examples。
help Get-Service -Examples
廣告