Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 588 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Determine installed PowerShell version

#21
PowerShell 7
================

The accepted answer is only appropriate if one version of PowerShell is installed on a computer. With the advent of PowerShell 7, this scenario becomes increasingly unlikely.

Microsoft's [documentation][1] states that additional registry keys are created when PowerShell 7 is installed:

> Beginning in PowerShell 7.1, the [installer] package creates registry keys
> that store the installation location and version of PowerShell. These
> values are located in
> `HKLM\Software\Microsoft\PowerShellCore\InstalledVersions\<GUID>`. The
> value of `<GUID>` is unique for each build type (release or preview),
> major version, and architecture.

Exploring the registry in the aforementioned location reveals the following registry value: `SemanticVersion`. This value contains the information we seek.

On my computer it appears like the following:

```none
Path Name Type Data
---- ---- ---- ----
HKLM:\SOFTWARE\Microsoft\PowerShellCore\InstalledVersions\31ab5147-9a97-4452-8443-d9709f0516e1 SemanticVersion String 7.1.3
```
[![Image displaying the specified key in the Windows Registry Editor][2]][2]

As you can see, the version of PowerShell 7 installed on my computer is 7.1.3. If PowerShell 7 is **not** installed on the target computer, the key in its entirety should not exist.

As mentioned in the Microsoft documentation, the registry path will be slightly different dependent on installed PowerShell version.

Part of the key path changing could pose a challenge in some scenarios, but for those interested in a command line-based solution, PowerShell itself can handle this problem easily.

The PowerShell cmdlet used to query the data in this registry value is the [`Get-ItemPropertyValue` cmdlet][3]. Observe its use and output as follows (note the asterisk [wildcard][4] character used in place of the part of the key path that is likely to change):
``` none
PS> Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\PowerShellCore\InstalledVersions\*" -Name "SemanticVersion"

7.1.3
```
Just a simple one-liner.

[1]:

[To see links please register here]

[2]:

[3]:

[To see links please register here]

[4]:

[To see links please register here]


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through