PowerShell Get-Hostでバージョンを確認する

環境
PowerShell 5.1.22621.963
Windows 10 Pro 64bit

操作方法
1.Get-HostコマンドでPowerShellのバージョンを確認します
Get-Host
実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
PS C:\Windows\system32> Get-Host
Name : ConsoleHost
Version : 5.1.22621.963
InstanceId : 56cae13e-67f1-470d-97fe-d0ccc43df69a
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : ja-JP
CurrentUICulture : ja-JP
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
PS C:\Windows\system32> Get-Host Name : ConsoleHost Version : 5.1.22621.963 InstanceId : 56cae13e-67f1-470d-97fe-d0ccc43df69a UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : ja-JP CurrentUICulture : ja-JP PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy DebuggerEnabled : True IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace
PS C:\Windows\system32> Get-Host


Name             : ConsoleHost
Version          : 5.1.22621.963
InstanceId       : 56cae13e-67f1-470d-97fe-d0ccc43df69a
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : ja-JP
CurrentUICulture : ja-JP
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

2.(Get-Host).Versionでバージョンを確認します
書式
(Get-Host).Version

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
PS C:\Windows\system32> (Get-Host).Version
Major Minor Build Revision
----- ----- ----- --------
5 1 22621 963
PS C:\Windows\system32> (Get-Host).Version Major Minor Build Revision ----- ----- ----- -------- 5 1 22621 963
PS C:\Windows\system32> (Get-Host).Version

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      22621  963

3.変数「$PSVersionTable」を使用して確認します
$PSVersionTable

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
PS C:\Windows\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22621.963
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.963
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\Windows\system32> $PSVersionTable Name Value ---- ----- PSVersion 5.1.22621.963 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.963 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
PS C:\Windows\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22621.963
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.963
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

 

PowerShell

Posted by arkgame