question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Powershell Framework is broken (again) under Powershell Core

See original GitHub issue

Prerequisites

Steps to reproduce

C:\Users\keith.russell>pwsh
PowerShell 7.2.1
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

   A new PowerShell stable release is available: v7.2.6
   Upgrade now, or check out the release page at:
     https://aka.ms/PowerShell-Release?tag=v7.2.6

PS C:\Users\keith.russell> cmd
Microsoft Windows [Version 10.0.19044.1889]
(c) Microsoft Corporation. All rights reserved.

C:\Users\keith.russell>powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

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

PS C:\Users\keith.russell> get-filehash
get-filehash : The term 'get-filehash' 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.

### Expected behavior

```console
C:\Users\keith.russell>pwsh
PowerShell 7.2.1
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

   A new PowerShell stable release is available: v7.2.6
   Upgrade now, or check out the release page at:
     https://aka.ms/PowerShell-Release?tag=v7.2.6

PS C:\Users\keith.russell> cmd
Microsoft Windows [Version 10.0.19044.1889]
(c) Microsoft Corporation. All rights reserved.

C:\Users\keith.russell>powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

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

PS C:\Users\keith.russell> get-filehash
get-filehash : The term 'get-filehash' 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.

Actual behavior

PS C:\Users\keith.russell> get-filehash

cmdlet Get-FileHash at command pipeline position 1
Supply values for the following parameters:
Path[0]:

Error details

get-filehash : The term 'get-filehash' 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:1
+ get-filehash
+ ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (get-filehash:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Environment data

PS C:\Users\keith.russell> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
tusharsnxcommented, May 12, 2023

As a workaround, you can import WinPS compatible ‘Microsoft.PowerShell.Utility’ which contains ‘Get-FileHash’ function:

Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash

This can be run at the top of the script.

0reactions
nannerpussercommented, Aug 2, 2023

As a workaround, you can import WinPS compatible ‘Microsoft.PowerShell.Utility’ which contains ‘Get-FileHash’ function:

Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash

This can be run at the top of the script.

For anyone having this crop up while using scoop (CLI or via WinGet UI, etc.) add that Import-Module command at the top of %SCOOP_DIR%\apps\scoop\current\lib\install.ps1 and carry on without frequent hash check failures.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Powershell broke - basic commands not working ...
At some point my Powershell broke. Standard commands like 'Write-Host' stopped working. I was using VS Code on Windows 10 and using ...
Read more >
Need to repair the windows powershell 5.1 to fix basic ...
I already have PowerShell Core installed and running. I would like to have both of them working simultaneously. Is there any other way...
Read more >
Resolving PowerShell module assembly dependency ...
This presents issues when a module's dependencies conflict with already-loaded DLLs and may prevent using two otherwise unrelated modules in the ...
Read more >
Differences between Windows PowerShell 5.1 and ...
This article summarizes the differences and breaking changes from Windows PowerShell 5.1 and the current version of PowerShell that is based ...
Read more >
Cannot install powershell modules - Microsoft Q&A
My problem is that I am not able to install modules to my powershell console. Example: Install-module -Name AzureAD.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found