$PSItem in PowerShell v3

by Oct 23, 2012

In PowerShell, the variable "$_" has special importance. It works like a placeholder in scenarios like this one:

PS> Get-ChildItem $env:windir | Where-Object { $_.Length -gt 1MB }

In PowerShell v3, there is an alias for the cryptic "$_": $PSItem. So now code can become more descriptive:

PS> Get-ChildItem $env:windir | Where-Object { $PSItem.Length -gt 1MB }

Then again, in PowerShell v3, "$_" isn't necessary in many scenarios anymore at all. You could also write:

Get-ChildItem $env:windir | Where-Object Length -gt 1MB 

Twitter This Tip! ReTweet this Tip!