# ヘルプの活用方法について ## help <コマンドレット名> で、指定したコマンドレットのヘルプを確認できる。 汎用的に利用できるコマンド。PowerShellのコマンドレットを効率よく理解する上で役に立ちます。 `Get-Help`コマンドも同じだが、`help`ならスペースキーでページを進めながら表示できるので、おすすめです。 `例 help Get-Process` ```.ps1 > help Get-Process Get-Help を実行しましたが、このコンピューターにこのコマンドレットのヘルプ ファイルは見つかりませんでした。ヘルプの一部だけが表示されています。 -- このコマンドレットを含むモジュールのヘルプ ファイルをダウンロードしてインストールするには、Update-Help を使用してください。 -- このコマンドレットのヘルプ トピックをオンラインで確認するには、「Get-Help Get-Process -Online」と入力するか、 https://go.microsoft.com/fwlink/?LinkID=113310 を参照してください。 ``` + 初回はヘルプファイルが見つからないと出るので、ヘルプを更新する必要がある。 管理者権限で`Update-Help -Force -UICulture en-US`を実行 日本語ヘルプを更新するとエラーが出るため、パラメータ`-UICulture`に「en-US」を指定する。 ヘルプが以下の項目別で正しく表示される。 + 名前 + 概要 + 構文 + 説明 + 関連リンク + 注釈 ```.ps1 > help Get-Process 名前 Get-Process 概要 Gets the processes that are running on the local computer or a remote computer. 構文 Get-Process [[-Name] <System.String[]>] [-ComputerName <System.String[]>] [-FileVersionInfo] [-Module] [<CommonPara meters>] Get-Process [-ComputerName <System.String[]>] [-FileVersionInfo] -Id <System.Int32[]> [-Module] [<CommonParameters> ] Get-Process [-ComputerName <System.String[]>] [-FileVersionInfo] -InputObject <System.Diagnostics.Process[]> [-Modu le] [<CommonParameters>] Get-Process -Id <System.Int32[]> -IncludeUserName [<CommonParameters>] Get-Process [[-Name] <System.String[]>] -IncludeUserName [<CommonParameters>] Get-Process -IncludeUserName -InputObject <System.Diagnostics.Process[]> [<CommonParameters>] 説明 The `Get-Process` cmdlet gets the processes on a local or remote computer. Without parameters, this cmdlet gets all of the processes on the local computer. You can also specify a particular process by process name or process ID (PID) or pass a process object through the pipeline to this cmdlet. By default, this cmdlet returns a process object that has detailed information about the process and supports metho ds that let you start and stop the process. You can also use the parameters of the `Get-Process` cmdlet to get file version information for the program that runs in the process and to get the modules that the process loaded. 関連するリンク Online Version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-process?view=power shell-5.1&WT.mc_id=ps-gethelp Debug-Process Get-Process Start-Process Stop-Process Wait-Process 注釈 例を参照するには、次のように入力してください: "get-help Get-Process -examples". 詳細を参照するには、次のように入力してください: "get-help Get-Process -detailed". 技術情報を参照するには、次のように入力してください: "get-help Get-Process -full". -- More -- ``` + 「構文」の項目の説明  コマンドを利用するときのパラメータの組み合わせパターンが表示される。例では6パターンあり、2つ以上のパターンを同時に使用することはできない。(-Nameを使ったときは-Idは利用できない)  「[]」で囲まれた場所は、省略可能。自動で値が入る。  string[]のような配列は「,」区切りで複数指定できる。 ## helpで利用できるパラメータを調べる ` help <コマンドレット> -Parameter *` パラメータを直接指定することもできます。 ` 例 help Update-Help -Parameter Force` ```.ps1 -Force <System.Management.Automation.SwitchParameter> Indicates that this cmdlet doesn't follow the once-per-day limitation, skips version checking, and downloads files that exceed the 1 GB limit. Without this parameter, `Update-Help` runs only once in each 24-hour period. Downloads are limited to 1 GB of uncom pressed content per module and help files are only installed when they're newer than the existing files on the comp uter. The once-per-day limit protects the servers that host the help files and makes it practical for you to add an `Upda te-Help` command to your PowerShell profile without incurring the resource cost of repeated connections or download s. To update help for a module in multiple UI cultures without the Force parameter, include all UI cultures in the sam e command, such as: `Update-Help -Module PSScheduledJobs -UICulture en-US, fr-FR, pt-BR` 必須 false 位置 named 既定値 False パイプライン入力を許可する False ワイルドカード文字を許可する false ``` + 必須(Required)がtrueのものは省略不可。 + 位置(Position)はパラメータを指定せずに値を渡せるかどうかを意味する。namedになっているとパラメータを指定する必要があり、0などの数値は省略可。 パラメータを付けない場合は、すべて表示される help Update-Help ```.ps1 名前 Update-Help 概要 Downloads and installs the newest help files on your computer. 構文 Update-Help [[-Module] <System.String[]>] [[-UICulture] <System.Globalization.CultureInfo[]>] [-Credential <System. Management.Automation.PSCredential>] [-Force] [-FullyQualifiedModule <Microsoft.PowerShell.Commands.ModuleSpecifica tion[]>] [-LiteralPath <System.String[]>] [-Recurse] [-UseDefaultCredentials] [-Confirm] [-WhatIf] [<CommonParamete rs>] Update-Help [[-Module] <System.String[]>] [[-SourcePath] <System.String[]>] [[-UICulture] <System.Globalization.Cul tureInfo[]>] [-Credential <System.Management.Automation.PSCredential>] [-Force] [-FullyQualifiedModule <Microsoft.P owerShell.Commands.ModuleSpecification[]>] [-Recurse] [-UseDefaultCredentials] [-Confirm] [-WhatIf] [<CommonParamet ers>] ``` ヘルプを見る際に便利なパラメータ + -Full:ヘルプのすべての結果が表示される。パラメータの一覧と説明、利用例、出力型など。常にこのパラメータを付けることが推奨。 + -Examples:利用例だけ表示。 + -Parameters:パラメータだけ表示。 + -Detailde:パラメータの詳細を表示するが、利用例は表示しない。 + -Online:ブラウザでヘルプを表示する。ヘルプファイルが更新されずWeb上だけで更新されることがよくあるらしい。 helpコマンドの後に文字列を置くと、その文字列が含まれるコマンドが出力される。 ```.ps1 > help item Name Category Module Synopsis ---- -------- ------ -------- Clear-Item Cmdlet Microsoft.PowerShell.M... Clears the contents of an item, but does not d... Clear-ItemProperty Cmdlet Microsoft.PowerShell.M... Clears the value of a property but does not de... Copy-Item Cmdlet Microsoft.PowerShell.M... Copies an item from one location to another. Copy-ItemProperty Cmdlet Microsoft.PowerShell.M... Copies a property and value from a specified l... Get-ChildItem Cmdlet Microsoft.PowerShell.M... Gets the items and child items in one or more ... Get-ControlPanelItem Cmdlet Microsoft.PowerShell.M... Gets control panel items. Get-Item Cmdlet Microsoft.PowerShell.M... Gets the item at the specified location. Get-ItemProperty Cmdlet Microsoft.PowerShell.M... Gets the properties of a specified item. Get-ItemPropertyValue Cmdlet Micros ~ ``` ## その他覚えておきたいコマンドレット + Get-Command + Get-Member 参照:https://docs.microsoft.com/ja-jp/powershell/scripting/learn/ps101/02-help-system?view=powershell-7.2