locked
Using Powershell to check highest CPU usage on multiple p.c.s RRS feed

  • Question

  • From my p.c., I want to get the highest 10 cpu processes on multiple remote p.c.s.  I thought I could create a text file listing the remote p.c.s, then using a variable in my code, connect to those remote systems and return the values to my p.c.

    Can you suggest some code that I can use?

    Thanks!

    Monday, September 18, 2017 9:10 AM

All replies

  • Hi Dirk,

    You can use the following commands to good effect:

    • Get-Content
      Reads a text file
    • Get-CimInstance Win32_Process
      Returns process information
    • Get-Help <CommandName> -Detailed
      Returns information on how to use a command, with examples and parameter explanation
    • Set-Content
      Writes output to a text-file
    • Export-Csv
      Writes Output to a csv-file

    Cheers,
    Fred

    Edit: Alternatively you may be able to find a finished script for this in the gallery.


    There's no place like 127.0.0.1


    • Edited by FWN Monday, September 18, 2017 9:18 AM
    • Proposed as answer by jrv Monday, September 18, 2017 9:31 AM
    Monday, September 18, 2017 9:17 AM
  • Hi Dirk,

    I agree with FWN.

    Also, you could have a try with the following scripts. Hope it is helpful to you:
    Invoke-Command -ComputerName (Get-Content <Path>) -ScriptBlock {Get-Process | Sort-Object CPU -Descending | Select-Object PSComputerName,ProcessName,CPU -First 10} | Export-Csv <Path> -NoTypeInformation

    If you need further help, please feel free to let us know.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, September 19, 2017 3:03 AM
  • Hi,

    Just checking in to see if the information provided was helpful. Does the script work?

    Please let us know if you would like further assistance.

    Best Regards,
    Albert Ling


    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, September 22, 2017 5:59 AM
  • Hi,

    I am checking how the issue is going, if you still have any questions, please feel free to contact us.

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.

    Appreciate for your feedback.

    Best Regards,
    Albert Ling


    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, September 27, 2017 8:15 AM