Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get-filehashes module foreach error #153

Open
1amr00t opened this issue Oct 25, 2016 · 8 comments
Open

get-filehashes module foreach error #153

1amr00t opened this issue Oct 25, 2016 · 8 comments
Labels

Comments

@1amr00t
Copy link

1amr00t commented Oct 25, 2016

Environment: PSv4 on target and source. Run as user with admin on both systems and with scripts "unblocked". Latest Kansa code.

Issue: When running the Get-FileHashes module against a single target host, I get the following error:

"Get-FileHashes reports error on COMPUTERNAME: "Missing opening '(' after keyword 'foreach'."

The command run is:

KANSAPATH\kansa.ps1 -Target COMPUTERNAME -ModulePath "KANSAPATH\Modules\Disk\Get-FileHashes.ps1 MD5,C:\Users\"

Thanks in advance!

@jt-msft
Copy link
Collaborator

jt-msft commented Oct 25, 2016

Can you try changing the conditional in Get-FileHashes.ps1 on line 232 from -gt 2.0 to -gt 8.0 or some other value that will never be true? I think this is due to the -parallel flag in that function, but this should let us know for sure.

@1amr00t
Copy link
Author

1amr00t commented Oct 25, 2016

Changing the -gt 2.0 condition to -gt 8.0 returned the same error.

@jt-msft
Copy link
Collaborator

jt-msft commented Oct 25, 2016

Thanks. I'll dive into it some more.

@jt-msft jt-msft added the bug label Oct 25, 2016
@mattfrancois25
Copy link

I get the same error on the following modules:

Get-FileHashes
Get-FilesByHash
Get-FilesByHashes

@athegist
Copy link
Collaborator

@z4ns4tsu were you ever able to repro this? I need to try it in my lab, but the code clearly has a check for PS version and should work.

@slw07g
Copy link
Contributor

slw07g commented Nov 9, 2017

Why isn't $(Get-FileHash $File -Algorithm SHA256).Hash used instead?

@athegist
Copy link
Collaborator

Because Get-FileHash isn't on every system with PowerShell, unfortunately. Not sure when that came in as a first order cmdlet, PSv4 maybe? There's still a huge install base of PSv2, sadly.

@Skwerl23
Copy link

Windows 10 doesn't do md5 hashes. To fix this go through all the hashing scripts and change md5 to sha512 or sha1 where it calls it. Or remove the call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants