# Get-Host

**URL:** <https://forums.powershell.org/t/get-host/1840>\
**Category:** PowerShell Help\
**Created:** [August 28, 2013, 9:55pm UTC](https://forums.powershell.org/t/get-host/1840 "2013-08-28T21:55:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas-franke](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@thomas-franke](https://forums.powershell.org/u/thomas-franke)\
**Post date:** [August 28, 2013, 9:55pm UTC](https://forums.powershell.org/t/get-host/1840/1 "2013-08-28T21:55:59Z")

</div>

Determining the powershell version can be important. Often this is done by using the Get-Host cmdlet. I read somewhere that this command returns the version of the powershell host, not the version of powershell itself.

Question: The powershell and the powershell host usually have the same version. Is there any case when the versions differ from each other?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [August 28, 2013, 10:42pm UTC](https://forums.powershell.org/t/get-host/1840/2 "2013-08-28T22:42:20Z")

</div>

If you’re talking about the Console and ISE, the versions will probably always match the PowerShell version. Developers can write their own custom hosts, though, which would have their own version scheme.

---

<div class="post-metadata">

**Author:** ![richard-siddaway](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@richard-siddaway](https://forums.powershell.org/u/richard-siddaway)\
**Post date:** [August 29, 2013, 12:03am UTC](https://forums.powershell.org/t/get-host/1840/3 "2013-08-29T00:03:17Z")

</div>

In PowerShell 2.0 and above you can also use the $psversiontable variable which will give some additional interesting info such as wsman version and CLR version

$psversiontable will give the powershell version rather than the host version

---

<div class="post-metadata">

**Author:** ![thomas-franke](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@thomas-franke](https://forums.powershell.org/u/thomas-franke)\
**Post date:** [August 29, 2013, 12:33am UTC](https://forums.powershell.org/t/get-host/1840/4 "2013-08-29T00:33:11Z")

</div>

Thank you!

So Get-Host will usually return the right value, but might be wrong in some Special cases.  
$psversiontable will fail on Powershell V1 but I found a great Workaround:

`
# If the $PSVersionTable variable doesn't exist, then you are running V1.  
# If it does exist, then the version will be available as $PSVersionTable.PSVersion.  
`

`function Get-PSVersion {
if (test-path variable:psversiontable) {$psversiontable.psversion} else {[version]“1.0.0.0”}
}
`

Source: [http://powershell.com/cs/media/p/2617.aspx](http://powershell.com/cs/media/p/2617.aspx)

In the end I decided to avoid getting and processing the version info and inserted a “#Requires -version 3.0” statement instead.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:57pm UTC](https://forums.powershell.org/t/get-host/1840/5 "2024-05-16T20:57:06Z")

</div>


