Identifying PowerShell Host

by Jul 31, 2012

If your script requires a real console, or if your script requires PowerShell ISE features, it may be a wise thing to check which host is actually running your script.

Here's a one-liner that tells you the name of the current host application:

PS> (Get-Process -id $PID).ProcessName

Another option would be to retrieve the internal host name like this:

PS> (Get-Host).Name

Twitter This Tip! ReTweet this Tip!