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?

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.

  • 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. – Ryan Bolger Sep 29 '19 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. – Ryan Bolger Sep 29 '19 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.