Open vojtech-kasny opened 1 year ago
@vojtech-kasny is there something you can't seem to do in PowerShell 7 (PowerShell Core) that only works in Windows PowerShell?
@StevenBucher98
Hello
Yes, unfortunately, our company environment is not ready yet for PS core, so we still need to use PowerShell Windows scripts with backward compatibility for PowerShell 2.0
(yes, this is sad reality )
I performed couple of tests, how to make it work from the notebook, there is small possibility to switch to Windows PowerShell, but with limited functionality
This works:
command:
powershell -version 2.0 -c "get-host;get-wmiobject win32_bios"
output:
Name : ConsoleHost
Version : 2.0
InstanceId : 9ce2458a-9938-4406-874c-2f12762265d9
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
SMBIOSBIOSVersion : T95 Ver. 01.01.05
Manufacturer : HP
Name : T95 Ver. 01.01.05
SerialNumber : CGD1473QG1
Version : HPQOEM - 0
this does not work: command:
powershell -version 2.0 -c "$host;get-wmiobject win32_bios"
output:
System.Management.Automation.Internal.Host.InternalHost : The term 'System.Management.Automation.Internal.Host.Internal
Host' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:56
+ System.Management.Automation.Internal.Host.InternalHost <<<< ;get-wmiobject win32_bios
+ CategoryInfo : ObjectNotFound: (System.Manageme...st.InternalHost:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
So there are some limitations, which needs to be taken in consideration Also switching to Windows PowerShell using this way for more complex notebook is not ideal
For others that might find this thread, if using Windows PowerShell you should consider continuing to use Powershell ISE that ships with Windows.
@vojtech-kasny just wanted to bring to your attention that PowerShell 2 has been deprecated for over 5 years, https://devblogs.microsoft.com/powershell/windows-powershell-2-0-deprecation/, and if possible, recommend folks move away from that version.
@StevenBucher98 I am aware that PS 2.0 has been deprecated for long time, but we have so complex infrastructure, that some customers are still running even NT servers because of some crappy applications and there is no way how to force them to migrate to higher OS version :) So unfortunately, we still need to support all our scripts, especially for incident automation, for PS 2.0 and above, and sometimes it's real pain Just to give you some overview, we have around 25K Windows servers, where our scripts are running, and there are any possible OS versions installed, starting with NT ending with lates 2022 :)
The package and version I'm asking about:
Question
Hello.
Is there any way to run Windows PowerShell (desktop edition) instead of PowerShell core?
Thank you