Resource Usage in Powershell Script

To get all the detail from processors

Get-WmiObject win32_processor

To shows the CPU load in every 5 sec

while ($true) {
    Start-Sleep -s 5
    cls
    ‘CPU Load is’
    Get-WmiObject win32_processor | select LoadPercentage  |fl
}

To list all the processes (like ps in Linux)

get-process
will produce the following preocess list...
Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
    146       7     4992       1844    52     0.92    268 ACLIENT
     59       8     1188       2176    31     0.11   5948 AClntUsr
    136       5     4496       7132    49     4.55   5412 acrotray
    139       3     1728       3540    33     0.30   4192 AeXAgentUIHost
   1792     143    54748      11296   270   570.22    924 AeXNSAgent
    110       5     1364       1784    33            2388 alg
    257       6    15080      13104    89   124.14   1744 ArelliaACSvc
     31       2      488        764    15     0.06    956 CCSRVC
    113       4     1636       2928    42     0.08   2276 Client
     33       2     2160       2996    30     0.02   3588 cmd
     61       3     1384       1432    25     0.05   1952 CNTAoSMgr
    949      23    35120      31764   200    11.52   4216 communicator
    123       4     1532       2540    41     0.03   5132 concentr
   1102       8     3712       9140    74            2036 csrss
     79       4     1108       2364    31     0.06   5208 ctfmon
    675    5719    27204      26284   137   245.34   3212 explorer
     47       2     1572       2368    19     2.42   4244 FNPLicensingService
     91       3     1176       1840    33     0.06   3512 hkcmd
     29       2      576       1204    16     0.03   2332 hpmup094.bin
     90       5     4476       3504    52     0.03   6080 hqtray

get-process | where-object {$_.WorkingSet -gt 10000000}
to get those process name with higher working set.
stop-process –name processname
can be used to stop (kill) those processes

Some references

PowershellPro

The Powershell Guy

The Po$herLife

 

About henry416
I am a computer technology explorer and an university student based on Toronto. If you have any question, please feel free to discuss and comment here

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s