Skip navigation

Q. How do I access attributes of objects piped to other expressions?

A. When you use objects created out of expression output, you can access the object's individual attributes using the ($_.) syntax. This syntax is used in the following example, in which I list all processes using a working set of more than 100MB of memory. The command is

Users\john> get-process | Where-Object \{$_.WS -gt 100MB \}

The output is

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
221 21 85932 173084 286 1,413.35 3956 dwm
1136 83 300952 287540 537 1,814.53 18568 iexplore
4812 139 144088 173488 560 1,051.71 4812 OUTLOOK
810 37 151460 148220 295 463.00 316 svchost

Notice that I accessed the passed object's working set attribute. (If you wonder why Microsoft Internet Explorer--IE--is using nearly 300MB of memory, it's because I'm watching the first season of Lost in HD from the ABC Web site as I write this. I've never seen it before and thought I would give it a go.)

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish