Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
3.72k stars 514 forks source link

Windows Terminal - PowerShell Version 7 #3860

Open PetieM opened 2 years ago

PetieM commented 2 years ago

I'm not sure how feasible this is as I don't know if you can detect if more than one version is installed but on my Windows 10 PC, I have PowerShell 7 installed and use it as my primary shell on that machine. When connecting via either PowerShell option on the Terminal tab in MeshCentral though, it loads in the default v5 shell which isn't the end of the world but if it could use the latest version installed (or let you select the version), that would be great.

Also related, I see in #1142 that there was possibly going to be a UI change that would let us change the default shell - was that ever implemented?

Thank you as always for your continued hard work on this project!

krayon007 commented 2 years ago

Do you know a standard way to detect which powershell versions are installed? It would save me a bunch of time.

PetieM commented 2 years ago

I looked into it briefly before posting this and couldn't come up with a simple way to do it. I was hoping I was just missing something but it looks like it's fairly complicated. Windows 10 (and I assume 11) have v5.1 installed by default so they'll always show up but if you have other versions, most of the commands used to get the version number just return whatever shell they're being run in. Getting a full list of all of them doesn't seem to be possible from a simple command. I found a post (https://jdhitsolutions.com/blog/powershell/7447/get-installed-powershell-versions/) that seemingly does it but I don't know how reliable that would be in the long run so it's likely not worth exploring much. I'll keep researching but as it stands, this might not be possible at the moment.

smartekIT commented 2 years ago

Do you know a standard way to detect which powershell versions are installed? It would save me a bunch of time.

most of the time the following command, will get you the correct version:

$PSVersionTable.PSVersion
PetieM commented 2 years ago

most of the time the following command, will get you the correct version:

$PSVersionTable.PSVersion

This will give you the version of the shell it's running in but not all of the installed versions on the system so as far as I can tell, it can't be used to determine which version to use when connecting to a PowerShell session via MeshCentral.

si458 commented 1 year ago

ill add onto this, ive just started using powershell 7 and the is a way to detect if you have 5 or 7

powershell 5 uses powershell.exe where as powershell 7 uses pwsh.exe

if pwsh.exe exists and is run able, then you have 7 installed if not then u have 5 installed

i would love to be able to run the latest powershell 7 version if its installed!

krayon007 commented 1 year ago

Thanks for the update! I'll add this in there... I'll see if I can add a setting, so that it can be configured which one to use...