Interesting. I just attempted to upgrade PowerShell to the most recent version a few days ago. It’s been over 5 years since running Windows so I’m kind of rusty, sorry.
No problem.
I think I can see what’s going on here based on your previous post.
You are running the shipped powershell version with windows, hence the PSEdition Desktop.
That one is no longer being supported and I think they gonna let it stay there at version 5+. It also included pester, but that one also stuck at 3.4.0.
The modern and current one that getting update is cross platform and called PowerShellCore.
This is my info when i call $PSVersionTable
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
It is a bit annoying, but you can just go to their github page PS download and download the installer
or even better using winget (kinda like apt for linux), winget is auto included since win 10 winget
Afterward you can just launch the new powershell terminal, run:
Yep, your initial post sent me on my way to figuring this out, thanks.
Apt is specifically for Debian (and Debian derivatives), sorry for being pedantic as everyone would know what you mean. I’m really happy that there is command line package management for Windows and a shell I can work in to get my job done.
Thanks again for pointing me in the right direction.
Nevermind. I had too many terminals open and had not imported the pester module in the current window.
New error but may be related. If it’s a problem with my code, just say it’s expected. I thought the function is necessary for Pester to test the code.
> hello-world > Invoke-Pester
Starting discovery in 1 files.
Discovery found 1 tests in 101ms.
Running tests.
[-] HelloWorldTest.Outputs: 'Hello, World!' 61ms (47ms|14ms)
CommandNotFoundException: The term 'Get-HelloWorld' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at <ScriptBlock>, C:\Users\jdowning\Exercism\powershell\hello-world\HelloWorld.tests.ps1:7
Tests completed in 403ms
Tests Passed: 0, Failed: 1, Skipped: 0 NotRun: 0
Reopening because I get a related problem with the Grade School exercise.
Individual statements from the test work as expected when executed manually in a terminal, but fail under Invoke-Pester. An hour of back-and-forth with a genAI culminated with this explanation: “Creating an instance of [Roster] ensures PowerShell fully resolves all methods (including overloads) before any test executes,” and it suggested a patch to GradeSchool.tests.ps1:
BeforeAll {
. "./GradeSchool.ps1"
# Force class resolution
[void] [Roster]::new()
}
Sure enough, all tests pass after that adjustment. I submitted my code with exercism submit GradeSchool.ps1 and it also passed Exercism’s server-side checks, so perhaps the patch was only necessary on my workstation.
Please consider updating GradeSchool.tests.ps1 as above for future Exercism PowerShell learners? Thanks.