13.3. Getting Information About Objects

Quite often, we get an unidentified object from a cmdlet or another object. We were in that situation when we were working with AML objects previously. What can we do to get information about such objects? The answer is the Get-Member cmdlet. Get-Member lists an object's members: its properties, methods, fields, and so on. The easiest way to use it is to just pipe your objects through the cmdlet. Here is how we get a file item's properties:

PS> Get-Item test.txt | Get-Member TypeName: System.IO.FileInfo Name MemberType Definition ---- ---------- ---------- AppendText Method System.IO.StreamWriter App... CopyTo Method System.IO.FileInfo CopyTo(... Create Method System.IO.FileStream Create() CreateObjRef ...

Get Pro Windows PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.