monitor a task manager service

This topic contains 10 replies, has 5 voices, and was last updated by  iain Barnetson 3 weeks ago.

  • Author
    Posts
  • #103291

    rosse
    Participant

    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

  • #103294

    amit aman
    Participant

    No Formatting. But this will help.

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

    rosse
    Participant

    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 : (:) [Get-Process], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetProcessC
    ommand

    Do i just have to replace "name = 'ServiceName'" for it works??
    thanks

    • #103333

      amit aman
      Participant

      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"

  • #103334

    rosse
    Participant

    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 : (:) [Get-Process], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetProcessC
    ommand

  • #103372

    Fredrik Kacsmarck
    Participant

    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
    
  • #103408

    postanote
    Participant

    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.

    • #103426

      rosse
      Participant

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

    • #103429

      rosse
      Participant

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

    • #103430

      rosse
      Participant

      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

  • #103438

    iain Barnetson
    Participant

    1 line

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

You must be logged in to reply to this topic.