「$host」に関する考察
$hostに関してWebで情報が少ないので調べてみました。
概要
ホスト情報を格納。バージョン情報、色設定情報など。
型:System.Management.Automation.Internal.Host.InternalHost
確認方法
PS C:\> $host.GetType().FullName System.Management.Automation.Internal.Host.InternalHost
主要プロパティ
- Version:バージョン情報
- PrivateData:色設定情報
確認方法
PS C:\> $host | Get-Member
継承/実装元の型:System.Management.Automation.Host.PSHost
確認方法
PS C:\> $host.GetType().BaseType.FullName System.Management.Automation.Host.PSHost
継承階層
確認方法
PS C:\> $host.PSObject.TypeNames System.Management.Automation.Internal.Host.InternalHost System.Management.Automation.Host.PSHost System.Object
サンプル
バージョン情報の取得
PS C:\> $host.Version Major Minor Build Revision ----- ----- ----- -------- 1 0 0 0
色設定情報の取得
PS C:\> $host.PrivateData ErrorForegroundColor : Red ErrorBackgroundColor : Black WarningForegroundColor : Yellow WarningBackgroundColor : Black DebugForegroundColor : Yellow DebugBackgroundColor : Black VerboseForegroundColor : Yellow VerboseBackgroundColor : Black ProgressForegroundColor : Yellow ProgressBackgroundColor : DarkCyan
追記
「$host.ui」と「$host.ui.rawui」も後日紹介します。