foreach - How do I run two Powershell WMI queries simultaneously? -
i run 2 commands simultaneously. facing issue running commands serially perfmon info not matching stats.
below idea.
i running wmi_processes name command line. have application name in command way know name , idprocess.
then querying formatted perfmon info cpu usage. there delay in , of times miss details.
so there way can trigger both queries @ same time , work datasets only?
any other ideas welcome same solution. give thanks help.
update: trying processes ids matched, time search in below foreach loop execution may over. want them executed @ once. here code
$rec=get-wmiobject -query "select commandline,creationdate,handle,handlecount,name,processid,virtualsize,workingsetsize win32_process commandline 'dtexec%'" foreach ($p in $rec) { $psid=$p.processid $formatteddata=get-wmiobject -query "select elapsedtime,idprocess,percentprocessortime,percentusertime,percentprivilegedtime,ioreadbyte spersec,iowritebytespersec,privatebytes,workingset win32_perfformatteddata_perfproc_process 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 it?
powershell foreach wmi-query
No comments:
Post a Comment