monitor a task manager service

hello

I need toring the processor and memory use for the service below :

C:\Program Files (x86)\McAfee\VirusScan Enterprise\vstskmgr.exe

Could you help me please???
Thanks

No Formatting. But this will help.

$varService=Get-WmiObject Win32_Service -Filter "name = 'ServiceName'"
$PROCESSPIDs = $varService.ProcessID
Get-Process -Id $PROCESSPIDs | select CPU, WS

Hi and thanks

I have an issue (find below)

Get-Process : Impossible de lier l’argument au paramètre « Id », car il a la valeur Null.
Au caractère Ligne:4 : 17

  • Get-Process -Id $PROCESSPIDs | select CPU, WS
  •             ~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData : (:slight_smile: [Get-Process], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetProcessC
      ommand

Do i just have to replace “name = ‘ServiceName’” for it works??
thanks

Of course. Name = ServiceName is generic. You have to replace it with the name of service, you are seeking information for. In your case it is “vstskmgr

i undertand this amit but i have an error when i execute the script here i think : Get-Process -Id $PROCESSPIDs | select CPU, WS
in fact i would like to export the result of the task manager in a csv file
could you help me please??

Get-Process : Impossible de lier l’argument au paramètre « Id », car il a la valeur Null.
Au caractère Ligne:4 : 17

  • Get-Process -Id $PROCESSPIDs | select CPU, WS
  • CategoryInfo : InvalidData : (:slight_smile: [Get-Process], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetProcessC
    ommand

Since it says that the “Id” value is Null, it means that the $PROCESSPIDs variable is empty/null.

So if you run the first line, then just output the variable contents.
Does it list any information?

E.g.

$varService=Get-WmiObject Win32_Service -Filter "name = 'vstskmgr'"

$varService

You can get a list of services dynamically and avoid typos and the like.

# Present a list of services to select one
$ServiceName = (Get-Service) | Out-GridView -Title 'Select a service to monitor' -PassThru

# use the selected service and show the target information
$varService = Get-WmiObject Win32_Service -Filter "name = '$($ServiceName.Name)'"
$PROCESSPIDs = $varService.ProcessID
Get-Process -Id $PROCESSPIDs | select CPU, WS

You also turn this into a function with dynamic parameters to select from like the above.

yes you are right
when i put a correct name its ok thanks

ok thanks it works
but where i put the service name???

oh sorry i found : Select a service to monitor’
Other question :

when i launch the code the grid service is opening
i delete this code (Out-GridView -Title ‘Dhcp’ -PassThru) but where i put the name of the service now??
i also want need to concatene 3 different services and to export the code in an excel file. How to do please?
finally also need a new colum in the excel file with the date of the process check
thanks a lot for your help

1 line

Get-Process -Id (Get-WmiObject Win32_Service -Filter "name = 'masvc'").ProcessID | select  CPU, WS