Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Merge array combining by column.

$
0
0

I want to merge two arrays:

$cpudata = gps WmiPrvSE | select ProcessName, Id, CPU

$cpudata

Result (array1):

ProcessNameIdCPU

---------------------------

WmiPrvSE2708181,5383637

WmiPrvSE43920,2964019

WmiPrvSE47247,7064494

WmiPrvSE47923,7128238

WmiPrvSE511612,4644799

and second query:

$process = "WmiPrvSE.exe"

$javer = Get-WmiObject Win32_Process -Filter "name = '$process'" | select CommandLine, ProcessId

$javer

result (array2):

CommandLineProcessId

-------------------------------------------------

C:\windows\system32\wbem1\wmiprvse.exe2708

C:\windows\system32\wbem3\wmiprvse.exe4724

C:\windows\system32\wbem5\wmiprvse.exe5116

C:\windows\system32\wbem2\wmiprvse.exe4392

C:\windows\system32\wbem4\wmiprvse.exe4792

How merge this two arrays using Id = ProcessId.

Want to have result:

ProcessNameIdCPUCommandLine

-------------------------------------------

WmiPrvSE2708181,5383637C:\windows\system32\wbem1\wmiprvse.exe

WmiPrvSE43920,2964019C:\windows\system32\wbem2\wmiprvse.exe

WmiPrvSE47247,7064494C:\windows\system32\wbem3\wmiprvse.exe

WmiPrvSE47923,7128238C:\windows\system32\wbem4\wmiprvse.exe

WmiPrvSE511612,4644799C:\windows\system32\wbem5\wmiprvse.exe

How can I do that ?


Viewing all articles
Browse latest Browse all 6937

Trending Articles