Combining WMI cmdlets to export to csv

Welcome Forums General PowerShell Q&A Combining WMI cmdlets to export to csv

Viewing 4 reply threads
  • Author
    Posts
    • #275394
      Participant
      Topics: 1
      Replies: 1
      Points: 13
      Rank: Member

      Hope someone can help. Doesn’t seem like i can output it so that it can be properly exported. This is the best output i seem to be able to do.

      $qry1 = Get-wmiobject -class win32_perfformatteddata_perfproc_process | select WorkingSetPeak
      $qry2 = Get-WmiObject -class win32_process | select processname,commandline

      [pscustomobject]@{
      processname=$($qry2.processname)
      commandline=$($qry2.commandline)
      WorkingSetPeak=$($qry1.WorkingSetPeak)
      }

    • #275409
      Participant
      Topics: 5
      Replies: 252
      Points: 998
      Helping Hand
      Rank: Major Contributor

      Are you wanting something like the following in your csv?

      ProcessName, CommandLine, WorkingSetPeak

      “Hello”, “C:\Hello.exe”,”6160384″

      If so, I would just use Get-Process because it already has all the properties you want.

       

       

    • #275415
      Participant
      Topics: 1
      Replies: 1
      Points: 13
      Rank: Member

      Hi Mike,

      It was just an example. I know that the two cmdlets have those properties already. But there are some properties that i would like to take a little from both cmdlets and be able to combine them and export to csv.

      Hope this makes sense

    • #275418
      Participant
      Topics: 5
      Replies: 252
      Points: 998
      Helping Hand
      Rank: Major Contributor

      If you are combining properties, I assume in your hypothetical that the data is related by a common property like PID or path.  If so you can create a computed property like this for example:

       

    • #275421
      Participant
      Topics: 5
      Replies: 252
      Points: 998
      Helping Hand
      Rank: Major Contributor

      Here’s another example where I keyed off of the PID and Parent PID.

       

Viewing 4 reply threads
  • You must be logged in to reply to this topic.