Under The Hood Extensions

Thanks to all who attended the Technet webcast on PowerShell extensions. I’ve corrected the slide with the syntax for expressions. It will be included in the final PowerPoint file you can download from Microsoft. 

Here are some clearer examples on using expressions:

#another example with Get-Process
Get-Process | select Name,ID,@{Name=”Working Set;`
Expression={”{0:N2}” -f ($_.Workingset/1mb)}}

#example with Format-Table
Get-Process |Format-Table Name,ID,StartTime,@{Label=”Age(min);`
Expression={(Get-Date).Subtract($_.startTime).Minutes}} -auto

The main difference between what you use for Select vs Format is that Select uses ‘Name’ and Format uses ‘Label’.

Attached you will find a zip file with my .ps1xml files for custom type and view extensions.  You’ll need to save them locally and use the appropriate Update cmdlet before you can use them.

I’ve divided up the content into separate ps1 files.  You should be able to run them as scripts or simply copy and paste the snippets into PowerShell. If you have any follow-up questions or comments, please post them in the PowerShell forum at ScriptingAnswers.com.  It is free, although you need to register.