Search code examples
powershellcpu-speed

retrieving cpu speed and remove } from output


I'm trying to get cpu speed.

This is what I've done so far

$cpu = [string](get-wmiobject Win32_Processor | select name)
$($cpu.split("@")[-1]).trim()

and my output is

2.40GHz}

How can I remove "}" from my output without having to play with string functions? Is there a better way to achieve my goal? Thanks in advance


Solution

  • PS > $p = Get-WmiObject Win32_Processor | Select-Object -ExpandProperty Name
    PS > $p -replace '^.+@\s'
    2.40GHz