PowerShellのバージョンを確認する方法

環境
Windows 10 home 64bit

方法1
構文
$PSVersionTable
変数「$PSVersionTable」を使用してPowerShellバージョンを確認します。

使用例

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

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

方法2
構文
Get-Host
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
PS C:\> Get-Host
Name : ConsoleHost
Version : 5.1.19041.1682
InstanceId : b85a6eef-15c9-4803-a6a5-e95afd97afc4
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:\> Get-Host Name : ConsoleHost Version : 5.1.19041.1682 InstanceId : b85a6eef-15c9-4803-a6a5-e95afd97afc4 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:\> Get-Host


Name             : ConsoleHost
Version          : 5.1.19041.1682
InstanceId       : b85a6eef-15c9-4803-a6a5-e95afd97afc4
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

方法3
構文
(Get-Host).Version
使用例

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

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  1682

 

PowerShell

Posted by arkgame