Here is a quick one-liner that identifies the full path to your current PowerShell host:
PS> (Get-Process -Id $pid).Path
The path tells you where your current host is located, and you can check whether your code is being executed in Windows PowerShell, PowerShell 7, or the PowerShell ISE.
In a similar approach, you can also find out the path of executables by name. For example, if you wanted to know where PowerShell 7 is installed on your system, try this:
PS C:\> (Get-Command -Name pwsh).Source
Of course, this line produces an error if the executable cannot be found. It must be located in one of the folders listed in $env:path.
ReTweet this Tip!
Powered by IDERA