Get-Host

Get host information (PowerShell Version and Region), Gets a reference to the current console host object.

Syntax
      Get-Host [CommonParameters]

Key
   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Details of the current host are also available via $ExecutionContext.Host

$ExecutionContext.Host.name will return ConsoleHost for the default PS command line, or Windows PowerShell IDE Host when running the IDE.

Examples

Display PowerShell version and regional information:

PS C:\> get-host

Display PowerShell version only:

PS C:\> get-host | select version
Version
-------
4.0

Or to get the major and minor PowerShell version numbers use the $host automatic variable:

PS C:\> $Host.Version

Resize the PowerShell window to 50 pixels high by 80 pixels wide:

PS C:\> $h = get-host
$win = $h.ui.rawui.windowsize
$win.height = 50
$win.width = 80
$h.ui.rawui.set_windowsize($win)

“I do a show. It comes on late at night on TV. And if that means I'm a late-night talk show host, then I guess I am, but in every other regard I resign my commission, I don't care for it” ~ Craig Ferguson

Related PowerShell Cmdlets:

get the Operating System version
Read-Host - Read a line of input from the host console.
Clear-Host - Clear screen (cls).
Out-Host - Send the pipelined output to the host.
Write-Host - Display objects through the user feedback mechanism.


 
Copyright © SS64.com 1999-2019
Some rights reserved