Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Who’s Driving this Shell?

Posted on August 8, 2017

Microsoft has been busy with the next iteration of PowerShell. As you should already know, this version will run cross-platform. The executable, or engine, is naturally different than what you are used to with Windows PowerShell. As I was trying out the latest PowerShell beta, I needed to identify the path to the current PowerShell engine. I then thought it might be helpful to get even more details so I put together a quick PowerShell function called Get-PowerShellEngine.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!

Getting the current PowerShell engine is pretty easy because we can use the built-in $pid variable which references the process ID for the current PowerShell session.

Get-Process -id $pid | Select -ExpandProperty Path

You can try that out in any PowerShell session and you should get a path like C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe or C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell_ise.exe.  But since I always want more, I decided to grab some additional properties from $PSVersionTable and $Host. The complete function is a gist on GitHub.

The default behavior is to return the path. But using the –Detail parameter writes a custom object to the pipeline.I had a lot of fun trying out in different PowerShell sessions.

2017-08-08_10-29-38

image

image

image

As you can see from the screen shots, not all properties may have a value depending on your operating system or hosting application. But this could change as the PowerShell betas advance and when we ultimately reach RTM. I hope you’ll give this a spin and let me know what you think. If you encounter problems, please post an issue on the gist page.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d