performancepowershellsortinglogfilecpu-speed

Need to measure sorting CPU speed in Powershell and write out to a file


Need to develop a script to measure sorting CPU speed in PowerShell and write out the following information to the log file every 30 minutes to 1 hour

MachineName Date Time sort100kseconds

A cherry on top could be to add something to count number of java.exe processes or users logged in to the stats.


Solution

  • You can use Get-CimInstance to get CPU specs. The class is Win32_Processor
    Run Get-CimInstance Win32_Processor | Select-Object *
    Then you work with the properties you want.

    As for the process, you can work with Get-Process cmdlet.
    Something like Get-Process *java*
    If there's more than one you also can work with it separately in a ForEach loop.

    https://learn.microsoft.com/en-us/powershell/module/cimcmdlets/get-ciminstance?view=powershell-7.1

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-process?view=powershell-7.1#:~:text=The%20Get%2DProcess%20cmdlet%20gets,the%20pipeline%20to%20this%20cmdlet.