Powershell – Properties and Methods of a cmdlet


Enumerate properties and methods

Get-Member
To list all methods and properties of an object, type:

Get-EventLog –List | Get-Member

To list only properties, type:

Get-EventLog –List | Get-Member –MemberType Properties

 
Select-Object
To select a specific property or method, type:

Get-Process | Select-Object name,id | Format-List

To select all object except the defined below, type:

Get-Process | Select-Object * -exclude site,container

In the next example we list the last 3 smallest files:

Get-ChildItem c:\windows\*.* | Sort-Object length -descending | Select-Object -last 3

 

In Depth
http://technet.microsoft.com/en-us/library/ee176854.aspx
http://technet.microsoft.com/en-us/library/ee176955.aspx

Tested With
PowerShell 4.0

Advertisements
Categories: Powershell | Leave a comment

Post navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: