Now Available:

Featured Resource:

line

Newsletter

Email Address:


line

Ask the Expert

Have a question for our resident expert? Email your questions to Greg.

« Exchange 2007 SP1 + RODC's = No Go. | Main | Do you Know your Domain & Forest Functional Levels? »

Don Jones’ Favorite PowerShell Cmdlets, Part 5 of 10: Select-Object

Sometimes PowerShell just gives too much. It’s a very giving shell, after all, but sometimes you just wish it would scale back a bit. And sometimes, it guesses wrong when it tries to read your mind. Two problems, one solution: Select-Object.

For example, sometimes I find that the output of Get-Service isn’t quite what I want. Sometimes I just want a list of service names and whether or not they’re running. Well, Select-Object (or its alias, Select) lets me get just what I want, by specifying the properties that PowerShell lists:

Get-Service | Select Name,Status

Sometimes, when I’m experimenting, I don’t want to have to wait for an entire list of objects to be returned. Select-Object can help with that, too:

Click past the fold for more…

Get-Service | Select -First 10

Combined with Sort-Object, this can be pretty cool:

Get-Process | Sort Handles | Select Name,ID,Handles -Last 10

That’s the top 10 consumers of process handles on your system, conveniently listing just the process’ names, IDs, and their handle usage. Experiment - what can Select-Object do for you?

Don Jones is the Lead Scripting Guru for SAPIEN Technologies and a Windows PowerShell MVP. He’s the co-author of Windows PowerShell: TFM, 2nd Edition and is the Windows PowerShell columnist for TechNet Magazine. Don is also the Director for the new centralized, independent PowerShell online community: www.PowerShellCommunity.org.

Get your hands on the full Don Jones Favorite Cmdlets Series at this address:
http://www.realtime-windowsserver.com/type/mt-search.cgi?tag=don%20jones%20favorite%20cmdlets&blog_id=1

TrackBack

TrackBack URL for this entry:
http://www.realtime-windowsserver.com/type/mt-tb.cgi/512

Post a comment

(All comments are approved by site leader before appearing here. Thanks for commenting!)

line

Greg Shields' Bio:

Greg Shields, is an independent author, instructor, and IT consultant based in Denver, Colorado, and a co-founder of Concentrated Technology. With nearly 15 years of experience in information technology, Greg has developed extensive experience in systems administration, engineering, and architecture specializing in Microsoft systems management, remote application, and virtualization technologies. Greg is a Contributing Editor for Redmond Magazine, MCPmag.com, and Virtualization Review Magazine and is the author of five books, including Windows Server 2008:  What’s New / What’s Changed. Greg is also a highly sought-after instructor and speaker, speaking regularly at conferences like TechMentor Events, and producing computer-based training curriculum for CBT Nuggets.  Greg is a recipient of Microsoft "Most Valuable Professional" award with a specialization in Windows Terminal Services.