Remove Empty Entries

One little known fact is that Where-Object is a cool and simple way of removing empty objects. Let's say you want to list all network adapters that have an IP address. You can simply add Where-Object and specify the object property that needs to have content:

Get-WmiObjectWin32_NetworkAdapterConfiguration | Where-Object { $_.IPAddress }

Twitter This Tip! ReTweet this Tip!


Posted Jul 22 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.