rapid7 / rex-powershell

Rex library for dealing with Powershell Scripts
Other
53 stars 34 forks source link

Update command.rb #24

Closed wo4haoren closed 3 years ago

wo4haoren commented 4 years ago

Add "Powershell::usev2" advance option.

bwatters-r7 commented 3 years ago

I'm no powershell guru, but this looks like we're specifying version2 as a boolean value? Will we never need to run version 3 or 4 (or more)? I'm possibly off-base, but I feel like this should be a numeric value to allow us future growth? Also, at the beginning of the method, the hash values are broken out with data definitions. It would be good to include the definition of this new option there.

gwillcox-r7 commented 3 years ago

To expand on @bwatters-r7's point above here is the official description for the --version option:

-Version
    Starts the specified version of Windows PowerShell.
    Enter a version number with the parameter, such as "-version 2.0".

And here are some test results:

C:\Users\gwillcox>powershell -version 7.0
Cannot start Windows PowerShell version 7.0 because it is not installed.

C:\Users\gwillcox>powershell -version 6.0
Cannot start Windows PowerShell version 6.0 because it is not installed.

C:\Users\gwillcox>powershell -version 5.2
Cannot start Windows PowerShell. No version of Windows PowerShell compatible to 5.2 is installed.

C:\Users\gwillcox>powershell -version 5.0
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

...*CUT FOR BREVITY*...

Loading personal and system profiles took 887ms.
PS C:\Users\gwillcox>
gwillcox-r7 commented 3 years ago

Gah really hate to do this but @wo4haoren your PR is trying to pull stuff in from your master branch. I'm going to open a separate PR and link to this one from there. The new PR should contain the edits to this PR which would be necessary to land this. I'll also make sure to credit you in the new PR seeing as you did most of the work on this.