PowerShell can instantiate and inspect .NET objects directly. The Get-Member CmdLet is central to this, as covered in Experimenting with PowerShell. A practical discovery strategy:
-
Instance members — pipe any object to
Get-Member:
powershell Get-EventLog -LogName System -Newest 1 | Get-Member -
Static members — use
[TypeName] | Get-Member -Static:
powershell [System.IO.File] | Get-Member -Static -
Reflection — query methods, properties, or members directly:
powershell [System.IO.File].GetMethods() | Where-Object { $_.Name -like '*Text*' } [System.IO.File].GetProperties() -
Loaded assemblies — list what .NET libraries are available in the current session:
```powershell```
-
Documentation — once you know the namespace/class, use Microsoft Learn for details.
This is especially useful when deciding which properties to include in reports, as in the [[BOOK SECTION] Step Two: Create the Script in Stages] script's ConvertTo-HTML -Property list.