PowerShell for Windows Admins

Sep 22 2018   5:24AM GMT

Determining the PowerShell host

Richard Siddaway Richard Siddaway Profile: Richard Siddaway


The PowerShell ecosystem is more diverse than it used to be which makes determining the PowerShell host a bit more difficult.

The variable $host, and its Name property, is a good starting point.

PS>  $host.Name


You get ConSoleHost if you’re running in the console.

For ISE you get –  Windows PowerShell ISE Host

And for VScode you get  –  Visual Studio Code Host


If you want to know the PowerShell version as well it’s a bit more awkward.

$host.Version works for the console and ISE as it returns the PowerShell version. In VScode however it returns the version of VScode.  The best route is to use



While you’re at it you may want to check the edition of PowerShell – Core or Desktop

PS>  $PSVersionTable.PSEdition

To make that a bit easier

function get-powershellhost {

New-Object -TypeName PSobject -Property @{
Hostname = $host.Name
PSversion = $PSVersionTable.PSVersion
PSEdition = $PSVersionTable.PSEdition



The function runs in the console, ISE and VScode and was tested across Windows PowerShell v5.1 and PowerShell v6.1

Feel free to add other information as required

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: