Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello community,
I have been unable to find semi decent assistance when it comes to powershell online so I figured i would ask you guys. Its really one issue and that is with the "where-object" command. When starting the command how do you know which variable to pass over ? For example if I wanted to do; get-process | where-object {$._................
what would i put after the underscore ? Where do i find the variables needed. I apologize if this is a tad out of scope.

Your question is not at all out of scope.
It's not $._, but just $_ which gives you the object that's being "piped in." Then you need to add the dot and a property or method of the object. For example, from Microsoft's web page:
Get-Process | Where-Object {$_.handles -gt 200}
handles is a property of the object.

to check the property or methods of an object I use the "Get-member" command. When i use that for your above example "get-process|get-member" I do not see handles as a property.
Also, if the where-object starts with $_ then were does the period come into play ?Thanks.

Also, if i see a property that i want to investagate more, how do i do that. For example if i use "get-service|get-member" and i see a property called "status", how do i find out more about the status property ?
This is alittle better than vbsript =)

Here are the first few lines of output when I do get-process|get-member:
TypeName: System.Diagnostics.ProcessName MemberType Definition
---- ---------- ----------
Handles AliasProperty Handles = HandlecountSo handles is just an alternative name for the Handlecount property.
The $_ object is treated just like any other object name syntactically. So the dot goes just after it, as in $_.handles.
I don't know the answer to your question about investigating a property. I use the Powershell User Guide which is in the program group under the Start menu. I'm in the process of learning Powershell myself.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |