GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — WIP - Implement Get-Hash cmdlet by iSazonov · Pull Request #3395 · PowerShell/PowerShell

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Mar 22, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

It is first experimental implementation Get-Hash cmdlet for https://github.com/PowerShell/PowerShell-RFC/blob/master/2-Draft-Accepted/RFC0018-Get-StringHash.md

  1. According to the RFC the type of Encoding parameter is FileSystemCmdletProviderEncoding but I had to use EncodingConversion class because the API contains useful methods and can be easily enhanced in future (to support full set of codepages). Now multiple Utility cmdlets uses it. In contrast, a code using FileSystemCmdletProviderEncoding type is distributed in FileProvider and it's hard to reuse it although it is designated as the preferred (?) in https://github.com/PowerShell/PowerShell-RFC/blob/master/1-Draft/RFC0020-DefaultFileEncoding.md We also talked about that we should rationalize the use of encoding so EncodingConversion class looks like the best option.
  2. Added ValueFromPipelineByPropertyName to Path parameter that is skipped in the RFC 0018.
  3. After the implementation we can really see that Path and InputString parameters have the same type and cannot be both ValueFromPipeline. Perhaps here we understand that it is better for UX to have both options and we should split on Get-FileHash and Get-StringHash still. Until concluding on this I haven't added pipeline tests. We follow Select-String pattern as suggested by Keith Hill (@rkeithhill).
  4. I wanted to implement ValidateEncoding attribute but was blocked so how to implement Tab Completion. I need help. We should follow Unify file encoding when a cmdlet creates a file #4119.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dilijev and boernsen-development reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-already-signed label Mar 22, 2017
@rkeithhill

Keith Hill (rkeithhill) commented Mar 22, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

RE # 3, try changing the InputString type to PSObject[] and then convert each PSObject ToString before hashing. That should get you around the pipeline binding issue. This pattern in common for cmdlets that take both an InputObject and Path parameters like Select-String.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daxian-dbw Dongbo Wang (daxian-dbw) self-assigned this Mar 22, 2017
@iSazonov

Ilya (iSazonov) commented Mar 23, 2017

Copy link
Copy Markdown
Collaborator Author

Keith Hill (@rkeithhill) Thanks for workaround! The code looks not pretty. But I am ready to try this if community votes for this.

Can we introduce new Path type to resolve such problems? (This can be a lot of work)

public class PSPath : PSObject
{
    string Path;
    public string ToString()
    {
        return Path;
    }
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rkeithhill

Keith Hill (rkeithhill) commented Mar 23, 2017

Copy link
Copy Markdown
Collaborator

If you look at the SelectStringCommand impl -

PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs

Line 1009 in 02b5f35

[FileinfoToString]
it appears you use the FilenfoToString argument transform attribute on the Path/LiteralPath parameters.

TravisEz13 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov Ilya (iSazonov) added the Review - Needed The PR is being reviewed label Mar 23, 2017
@iSazonov

Ilya (iSazonov) commented Mar 23, 2017

Copy link
Copy Markdown
Collaborator Author

How do the attribute help to resolve conflict of parameter bindings?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rkeithhill

Keith Hill (rkeithhill) commented Mar 23, 2017

Copy link
Copy Markdown
Collaborator

Given that this attribute is private I've not had the chance to use it. However, it makes Select-String work so I'm assuming here it should make Get-Hash work as well. If you look at the parameter config for Select-String it is very similar to Get-Hash:

    Command: Microsoft.PowerShell.Utility/Select-String
    Set:    File *


Name                   Aliases      Position Mandatory Pipeline ByName Provider        Type
----                   -------      -------- --------- -------- ------ --------        ----
AllMatches             {A*}         Named    False     False    False  All             SwitchParameter
CaseSensitive          {Ca*}        Named    False     False    False  All             SwitchParameter
Context                {Co*}        Named    False     False    False  All             Int32[]
Encoding               {En*}        Named    False     False    False  All             String
Exclude                {Ex*}        Named    False     False    False  All             String[]
Include                {Inc*}       Named    False     False    False  All             String[]
List                   {Lis*}       Named    False     False    False  All             SwitchParameter
NotMatch               {N*}         Named    False     False    False  All             SwitchParameter
Path                   {}           1        True      False    True   All             String[]
Pattern                {Patt*}      0        True      False    False  All             String[]
Quiet                  {Q*}         Named    False     False    False  All             SwitchParameter
SimpleMatch            {S*}         Named    False     False    False  All             SwitchParameter


    Command: Microsoft.PowerShell.Utility/Select-String
    Set:    Object


Name                   Aliases      Position Mandatory Pipeline ByName Provider        Type
----                   -------      -------- --------- -------- ------ --------        ----
AllMatches             {A*}         Named    False     False    False  All             SwitchParameter
CaseSensitive          {Ca*}        Named    False     False    False  All             SwitchParameter
Context                {Co*}        Named    False     False    False  All             Int32[]
Encoding               {En*}        Named    False     False    False  All             String
Exclude                {Ex*}        Named    False     False    False  All             String[]
Include                {Inc*}       Named    False     False    False  All             String[]
InputObject            {Inp*}       Named    True      True     False  All             PSObject
List                   {Lis*}       Named    False     False    False  All             SwitchParameter
NotMatch               {N*}         Named    False     False    False  All             SwitchParameter
Pattern                {Patt*}      0        True      False    False  All             String[]
Quiet                  {Q*}         Named    False     False    False  All             SwitchParameter
SimpleMatch            {S*}         Named    False     False    False  All             SwitchParameter


    Command: Microsoft.PowerShell.Utility/Select-String
    Set:    LiteralFile


Name                   Aliases      Position Mandatory Pipeline ByName Provider        Type
----                   -------      -------- --------- -------- ------ --------        ----
AllMatches             {A*}         Named    False     False    False  All             SwitchParameter
CaseSensitive          {Ca*}        Named    False     False    False  All             SwitchParameter
Context                {Co*}        Named    False     False    False  All             Int32[]
Encoding               {En*}        Named    False     False    False  All             String
Exclude                {Ex*}        Named    False     False    False  All             String[]
Include                {Inc*}       Named    False     False    False  All             String[]
List                   {Lis*}       Named    False     False    False  All             SwitchParameter
LiteralPath            {PSPath, ... Named    True      False    True   All             String[]
NotMatch               {N*}         Named    False     False    False  All             SwitchParameter
Pattern                {Patt*}      0        True      False    False  All             String[]
Quiet                  {Q*}         Named    False     False    False  All             SwitchParameter
SimpleMatch            {S*}         Named    False     False    False  All             SwitchParameter

Path and LiteralPath are pipeline bound by property name and are of type string[]. InputObject is bound by value and is of type PSObject. Somehow Select-String takes both string input to search through (bound to InputObject) and FileInfo objects from Get-ChildItem/Item.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov Ilya (iSazonov) mentioned this pull request May 25, 2017
No equivalent of Get-FileHash for text blobs, requires writing input to file to test output #3861
Closed
@daxian-dbw Dongbo Wang (daxian-dbw) assigned Travis Plunk (TravisEz13) and unassigned Dongbo Wang (daxian-dbw) Jun 23, 2017
@daxian-dbw

Dongbo Wang (daxian-dbw) commented Jun 23, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Travis Plunk (@TravisEz13) I have my hands full and thus re-assigned this PR to you. Could you please help drive it?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Jun 23, 2017

Copy link
Copy Markdown
Collaborator Author

I'll continue on next week.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@daxian-dbw

Dongbo Wang (daxian-dbw) commented Jun 23, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Ilya (@iSazonov) No rush at all 😄 I was the assignee previously but I have too much on my plate right now and thus I reassigned this PR to Travis. That comment is just to let Travis know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13

Travis Plunk (TravisEz13) commented Jul 21, 2017

Copy link
Copy Markdown
Member

Ilya (@iSazonov) We should close inactive PRs and reopen the PR when it's active. Any issues?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Jul 21, 2017

Copy link
Copy Markdown
Collaborator Author

I'm going to give my time and finish my work.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov
Ilya (iSazonov) force-pushed the gethashrfc branch 4 times, most recently from 73a5efc to 8db565d Compare July 24, 2017 13:40
@iSazonov

Ilya (iSazonov) commented Jul 24, 2017

Copy link
Copy Markdown
Collaborator Author

Ready for a code review.
I corrected the PR desciption and cleaned up test.
We have a conflict with #4119 for Encoding parameter.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13

Travis Plunk (TravisEz13) commented Jul 24, 2017

Copy link
Copy Markdown
Member

Please use the present tense, imperative style for commit messages and title per Contribution Guide

iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13 Travis Plunk (TravisEz13) added Breaking-Change breaking change that may affect users and removed Breaking-Change breaking change that may affect users labels Jul 24, 2017
TravisEz13
Travis Plunk (TravisEz13) previously requested changes Jul 24, 2017
View reviewed changes
Comment thread test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Hash.Tests.ps1 Outdated

@TravisEz13 Travis Plunk (TravisEz13) Jul 24, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test for piping a file. The equivalent of dir * -File | Get-FileHash

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TravisEz13 Travis Plunk (TravisEz13) Jul 24, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure compatibility

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Jul 25, 2017

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the test .

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TravisEz13 Travis Plunk (TravisEz13) Jul 25, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#resolved

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@TravisEz13

Travis Plunk (TravisEz13) commented Jul 24, 2017

Copy link
Copy Markdown
Member

Berhe (@BerheAbrha) Can you review to ensure this won't cause issues for PowerShell DSC?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov Ilya (iSazonov) changed the title First experimental implementation Get-Hash cmdlet Implement Get-Hash cmdlet Jul 25, 2017
@iSazonov
Ilya (iSazonov) force-pushed the gethashrfc branch from 38c0e98 to b05e18f Compare July 25, 2017 10:05
@TravisEz13

Travis Plunk (TravisEz13) commented Jul 25, 2017

Copy link
Copy Markdown
Member

You have a test error in travis-ci

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13
Travis Plunk (TravisEz13) dismissed their stale review July 25, 2017 16:22

issues resolved

@iSazonov
Ilya (iSazonov) requested review from James Truher (JamesWTruher), Paul Higinbotham (PaulHigin) and sergei (vors) as code owners August 17, 2017 07:56
@iSazonov
Ilya (iSazonov) force-pushed the gethashrfc branch from cb1e91c to 3feeafa Compare August 17, 2017 14:16
@TravisEz13
Travis Plunk (TravisEz13) dismissed Jason Shirk (lzybkr)’s stale review August 17, 2017 16:21

code has changed

@msftgits Microsoft GitHub User (msftgits) removed the cla-already-signed label Sep 26, 2017
@TravisEz13

Travis Plunk (TravisEz13) commented Dec 15, 2017

Copy link
Copy Markdown
Member

Ilya (@iSazonov) merge conflicts need to be resolved

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov
Ilya (iSazonov) force-pushed the gethashrfc branch from 3feeafa to bf47787 Compare December 19, 2017 18:00
Ilya (iSazonov) and others added 5 commits December 20, 2017 00:12
@iSazonov
Implement Get-Hash cmdlet
fe11148
@iSazonov
Cleanup tests
f09a80b
@iSazonov
Add test for piping a path
94a4c98
@iSazonov
Address code review
e9a5583
1. Replace GetFileHashCommand with GetHashCommand
2. Exclude an exception
3. Fix tests.
@lzybkr @iSazonov
Tabs to spaces
59c9996
@iSazonov
Ilya (iSazonov) force-pushed the gethashrfc branch from bf47787 to 59c9996 Compare December 19, 2017 19:17
@TravisEz13

Travis Plunk (TravisEz13) commented Jan 3, 2018

Copy link
Copy Markdown
Member

Tests are failing

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Jan 4, 2018

Copy link
Copy Markdown
Collaborator Author

This is too old code. I will update it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13 Travis Plunk (TravisEz13) changed the title Implement Get-Hash cmdlet WIP - Implement Get-Hash cmdlet Jan 11, 2018
@stale

stale Bot commented Mar 16, 2018

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days. Thank you for your contributions.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@stale stale Bot added the Stale label Mar 16, 2018
@iSazonov Ilya (iSazonov) mentioned this pull request Mar 21, 2018
Change Get-FileHash tests to use raw bytes #6430
Merged
8 of 11 tasks
@stale

stale Bot commented Mar 27, 2018

Copy link
Copy Markdown

This PR has be automatically close because it is stale. If you wish to continue working on the PR, please first update the PR, then reopen it.
Thanks again for your contribution.
Community members are welcome to grab these works.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@stale stale Bot closed this Mar 27, 2018
@joeyaiello Joey Aiello (joeyaiello) mentioned this pull request Oct 15, 2018
Docs needed for 'WIP - Implement Get-Hash cmdlet' MicrosoftDocs/PowerShell-Docs#3106
Closed
@joeyaiello Joey Aiello (joeyaiello) removed Documentation Needed in this repo Documentation is needed in this repo labels Oct 15, 2018
@iSazonov
Ilya (iSazonov) deleted the gethashrfc branch May 15, 2020 13:26
@iSazonov
Ilya (iSazonov) restored the gethashrfc branch May 15, 2020 13:27
@iSazonov Ilya (iSazonov) mentioned this pull request May 15, 2020
Get-StringHash (something like Get-FileHash but not file based) #12531
Closed
@boernsen-development

boernsen (boernsen-development) commented Dec 16, 2025

Copy link
Copy Markdown

Please reopen this :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Stale label Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@TravisEz13 Travis Plunk (TravisEz13) TravisEz13 left review comments
@dantraMSFT Dan Travison (dantraMSFT) Awaiting requested review from dantraMSFT
@BrucePay Bruce Payette (BrucePay) Awaiting requested review from BrucePay
@daxian-dbw Dongbo Wang (daxian-dbw) Awaiting requested review from daxian-dbw
@JamesWTruher James Truher (JamesWTruher) Awaiting requested review from JamesWTruher
@PaulHigin Paul Higinbotham (PaulHigin) Awaiting requested review from PaulHigin
@vors sergei (vors) Awaiting requested review from vors
+1 more reviewer
@lzybkr Jason Shirk (lzybkr) lzybkr left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@TravisEz13 Travis Plunk (TravisEz13)

Labels

Review - Needed The PR is being reviewed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

9 participants

@iSazonov @rkeithhill @daxian-dbw @TravisEz13 @boernsen-development @lzybkr @joeyaiello @msftclas @msftgits
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.