Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Help with filtering result sets

 
Logged in as: Guest
arrSession:exec spGetSession 2,5,39797
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Windows PowerShell >> Help with filtering result sets
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Help with filtering result sets - 11/16/2006 12:30:59 AM   
  ginolard


Posts: 965
Score: 21
Joined: 8/10/2005
Status: offline
Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | ForEach-Object {Get-ItemProperty $_.pspath "DisplayName"} | Sort-object DisplayName | format-list DisplayName

That will list every installed software item's DisplayName value.  However, I'd like to filter out the following

  • Entries without a DisplayName value
  • Anything with "Update for Windows" or "HotFix" in its DisplayName
What's the best method?

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm
 
 
Post #: 1
 
 RE: Help with filtering result sets - 11/16/2006 1:14:49 AM   
  ebgreen


Posts: 4411
Score: 29
Joined: 7/12/2005
Status: offline
Look at the help for Where-Object.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ginolard)
 
 
Post #: 2
 
 RE: Help with filtering result sets - 11/16/2006 1:20:32 AM   
  ginolard


Posts: 965
Score: 21
Joined: 8/10/2005
Status: offline
Yeah I did that but I still couldn't figure out how to check for non-existant entries

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Help with filtering result sets - 11/16/2006 1:31:54 AM   
  SAPIENScripter


Posts: 261
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
This would be cumbersome to do in one line.  I would send the result of the Get-Childitem expression to a variable.  Then use an If statement to check for empty names or whatever else, then display the name or other information.

_____________________________

Jeffery Hicks
Windows PowerShell MVP
SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com

(in reply to ginolard)
 
 
Post #: 4
 
 RE: Help with filtering result sets - 11/19/2006 9:42:10 PM   
  ginolard


Posts: 965
Score: 21
Joined: 8/10/2005
Status: offline
This seems to do what I need.

gci hklm:\software\microsoft\windows\currentversion\uninstall -exclude KB* | %{(gp $_.pspath).DisplayName } | sort

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to SAPIENScripter)
 
 
Post #: 5
 
 RE: Help with filtering result sets - 7/16/2007 2:26:57 AM   
  wolfmandragon


Posts: 13
Score: 0
Joined: 7/13/2007
Status: offline
Great one liner. Very useful.

_____________________________

The Eyes of the Wolf is the Raven; The Ravens Teeth, the Wolf.

(in reply to ginolard)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Windows PowerShell >> Help with filtering result sets Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts