[Novice] - Obtaining CPU Percent Usage for Specific Process
greetings,
i'm brand new powershell, , haven't done scripting period apologize ignorance on issue. i'm trying solve issue thin-client application users can access client pc host server. when client pc opens thin-client, instance of process opened on host server.
if client pc fails close thin-client properly, instance on host server remains running until eats cpu usage enough crashes server. to alleviate this, figured i'd dig writing script automation purposes check specific .exe see if it's > cpu %, , if true, kill id of particular instance.
however, i'm having trouble determining how go pulling cpu usage particular process. using get-process doesn't seem give me information need. could kindly steer me in correct direction?
again, apologize. most of experience in handling such things have been on unix/linux system (i love how similar powershell linux user way!)
thank in advance.
there might better way this... may start ya:
get-wmiobject win32_perfformatteddata_perf proc_process | select-object name,percentprocessortime, idprocess #add next section select process > 50% cpu #| ? {$_.percentprocessortime -gt 50 -and $_.name -ne "idle" -and $_.name -ne "_total"} #add next line terminate processes... #| %{stop-process -id $_.idprocess} complete command: get-wmiobject win32_perfformatteddata_perfproc_process | select name,percentprocessortime, idprocess | ? {$_.percentprocessortime -gt 50 -and $_.name -ne "idle" -and $_.name -ne "_total"} | %{stop-process -id $_.idprocess}
g. samuel hays
Windows Server > Windows PowerShell
Comments
Post a Comment