0

I would like run two commands simultaneously. Currently I am facing an issue with running the commands serially as the perfmon data is not matching the stats.

Below is the idea.

  • I am running wmi_processes to get the name from the command line. As we have the application name in the command this is the only way to know the name and IDprocess.

  • Then I am querying the formatted perfmon data to get the CPU usage. But there is a delay in this and the most of the times I miss the details.

So is there any way I can trigger both the queries at the same time and work with the datasets only?

Any other ideas are most welcome to get the same solution. Thank you for the help.

Update: I am trying to get the processes IDs matched, but by the time i search in the below foreach loop the execution may be over. So i want them to be executed at once. Here is my code

$rec=Get-WmiObject -Query "select     CommandLine,CreationDate,Handle,HandleCount,Name,ProcessId,VirtualSize,WorkingSetSize from Win32_Process where commandline like 'Dtexec%'"
foreach ($P in $rec)
{
    $PsId=$P.ProcessId
    $FormattedData=Get-WmiObject -Query "select         ElapsedTime,IDProcess,PercentProcessorTime,PercentUserTime,PercentPrivilegedTime,IOReadByte    sPerSec,IOWriteBytesPerSec,PrivateBytes,WorkingSet from         Win32_PerfFormattedData_PerfProc_Process where IDProcess='$Psid'"
$Usage=$P.CreationDate+","+$PsId+","+$P.Handle+","+$P.HandleCount+","+$P.VirtualSiz    e+","+$FormattedData.IDProcess+","+$FormattedData.PercentProcessorTime+","+$FormattedData.E    lapsedTime+","+$FormattedData.PercentUserTime+","+$FormattedData.PercentPrivilegedTime+","+    $FormattedData.IOReadBytesPerSec+","+$FormattedData.IOWriteBytesPerSec+","+$FormattedData.P    rivateBytes+","+$FormattedData.WorkingSet+","+$P.CommandLine
    $Usage
}

So how can i do it?

5
  • Sorry, for me it's not clear, can you give the command lines of what you whant to do simultaneously ?
    – JPBlanc
    Jun 20, 2014 at 3:51
  • Show your code. You're wanting to run two commands simultaneously, what are the two commands? Jun 20, 2014 at 4:18
  • I have included the code. The second command also has a filter which i can put other than the processID. So if i can run both the get-wmi-object at once i can have the correct values.
    – Linu1988
    Jun 20, 2014 at 5:40
  • Your second command depends on the results of the first one, so I doubt that you could run them simultaneously. However, perhaps this is what you're looking for? Jun 20, 2014 at 7:48
  • Infact i can run them both at a time and after that i can filter out all of them with the same logic. But do i have a option to trigger them at once?
    – Linu1988
    Jun 20, 2014 at 11:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.