0

I have installed Powershell 7 core and trying to run get-counter but it says

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

Can any one help us to resolve this issue?

1 Answer 1

2

It wasn't available in PS 6.* either, so I'm not sure why its being raised as a problem now. For that matter, neither were any of the cmdlets from the Microsoft.PowerShell.Diagnostics module (or the module itself).

If you need this cmdlet to work on a Windows machine, you can leverage the WindowsCompatibility module to get it working:

Import-WinModule -Name Microsoft.PowerShell.Diagnostics

Edit: The cmdlet has returned (on Windows systems) in Powershell 7 Preview 6, here is a link to the announcement: https://devblogs.microsoft.com/powershell/powershell-7-preview-6/, so you will no longer have to import the module/cmdlet using WindowsCompatibility.

2
  • 7.0.0-preview.4 actually does contain a version of Microsoft.PowerShell.Diagnostics (version 7.0.0) in its embedded modules folder. But that version only appears to export Get-WinEvent and New-WinEvent. I also thought it was possible (on Windows at least) to load Windows PowerShell modules like version 3.0.0 in the legacy system32 module location that does export things like Get-Counter. But that doesn't seem to be working when I try importing with -RequiredVersion. Sep 29, 2019 at 19:06
  • From a Windows instance of preview-4, try the following. Get-Module -List Microsoft.PowerShell.Diagnostics and notice the 3.0.0 version lists Core compatibility in the PSEdition column. Sep 29, 2019 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .