PowerShell 버전 확인 방법
-
$PSVersionTable.PSVersion
속성을 사용하여 PowerShell 버전 얻기 -
(Get-Host).Version
속성을 사용하여 PowerShell 버전 가져오기 -
$host.Version
속성을 사용하여 PowerShell 버전 얻기 - 레지스트리를 사용하여 PowerShell 버전 얻기

PowerShell은 더 복잡한 유형의 명령 프롬프트입니다. 그것은 준비된 cmdlet의 대량과 다양한 시나리오에서 .NET 프레임워크/C#을 활용할 수 있는 능력을 제공합니다. PowerShell ISE는 Windows에서 스크립트를 디버그하고 편집하기 위한 그래픽 사용자 인터페이스입니다. PowerShell에서는 동일한 작업을 서로 다른 방법으로 수행할 수 있습니다. 따라서 주로 PowerShell 버전을 얻는 네 가지 방법이 있으며, 아래에 설명되어 있습니다.
$PSVersionTable.PSVersion
속성을 사용하여 PowerShell 버전 얻기
그래서 우리가 살펴볼 첫 번째 방법은 자동 변수 $PSVersionTable
의 PSVersion 속성입니다. 여기서 이는 PowerShell 엔진을 나타냅니다.
PS52> $PSVersionTable.PSVersion
출력:
Major Minor Build Revision
----- ----- ----- --------
5 1 19041 1320
$PSVersionTable
은 PowerShell 엔진 버전 및 PSEdition에 대한 정보를 제공하는 읽기 전용 해시 테이블입니다. 이 매개변수는 Desktop 또는 Core 중 하나일 수 있으며 사용 중인 PowerShell 에디션에 대한 추가 정보를 제공합니다.
자동 변수 $PSVersionTable
은 로컬에서도 원격에서도 동일하게 정확합니다. 아래 예제에서 $PSVersionTable.PSVersion
을 스크립트 블록 안에 포함시키고 원격 머신에서 실행하면 동일한 버전이 반환됩니다.
PS> Invoke-Command -ComputerName 11.0.0.3 -ScriptBlock {$PSVersionTable.PSVersion} -Credential $cred
출력:
(Get-Host).Version
속성을 사용하여 PowerShell 버전 가져오기
PowerShell에서 호스트의 개념이 사용됩니다. 문제를 일으키는 것은 PowerShell 엔진이 아닙니다. PowerShell 호스트는 내장 터미널이 있는 PowerShell 코드 편집기/콘솔입니다. 호스트는 완전히 독립적인 PowerShell 에디션을 가질 수 있습니다.
(Get-Host).Version
을 사용하면 PowerShell 버전과 유사한 버전 번호가 출력됩니다.
PS52> (Get-Host).Version
출력:
Major Minor Build Revision
----- ----- ----- --------
5 1 19041 1320
그러나 빌트인 터미널의 Get-Host 버전이 항상 동일하지는 않습니다. 호스트는 일반적으로 PowerShell 엔진의 동일한 에디션을 나타내지만 항상 그런 것은 아닙니다. 로컬 컴퓨터에서 Get-Host를 호출하면 항상 동일한 버전을 반환하지만 원격 시스템에서는 그렇지 않습니다.
따라서 모든 것에 대해 Get-Host를 사용하는 것은 끔찍한 아이디어입니다.
$host.Version
속성을 사용하여 PowerShell 버전 얻기
$host.Version
은 PowerShell 엔진 버전을 얻는 또 다른 방법입니다. Get-Host
는 $host 변수와 동일한 결과를 제공합니다. 이는 완전 자동 변수입니다.
PS52> $host.Version
출력:
Major Minor Build Revision
----- ----- ----- --------
5 1 19041 1320
이는 Get-host
방법과 꽤 유사합니다.
레지스트리를 사용하여 PowerShell 버전 얻기
PowerShell을 실행하는 데 관심이 없다면 레지스트리를 확인할 수도 있습니다. PowerShell의 에디션은 다음과 같은 레지스트리 키 경로 HKLM:\SOFTWARE\Microsoft\PowerShell\3\
에 저장되며 값으로 저장됩니다. Get-ItemProperty
는 이 레지스트리 항목의 PowerShellVersion 값을 참조하는 데 사용할 수 있습니다.
PS51> (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name 'PowerShellVersion').PowerShellVersion
출력:
5.1.19041.1
Nimesha is a Full-stack Software Engineer for more than five years, he loves technology, as technology has the power to solve our many problems within just a minute. He have been contributing to various projects over the last 5+ years and working with almost all the so-called 03 tiers(DB, M-Tier, and Client). Recently, he has started working with DevOps technologies such as Azure administration, Kubernetes, Terraform automation, and Bash scripting as well.