none
Select-String command RRS feed

  • Question

  • Hi everyone,

    I have a script below which displays everything that matches the keyword (such as security update and Office updates etc..).  How do I modify the above so that it only display the product installed (Microsoft Office 2010 or Microsoft Project 2010 etc.... 

    If not, how do I exclude certain keyword such as "Security" or "update" etc..?

    psinfo -s \\computername | Select-String 'Office','Project','Visio'

    Thanks in advance.

    Wednesday, March 25, 2015 9:23 PM

Answers

  • Possibly more intuitive than Select-String:

    (psinfo -s \\computername) -match 'Office','Project','Visio' -notmatch 'security|update'


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    • Proposed as answer by FaustoNascimento Friday, March 27, 2015 10:10 AM
    • Marked as answer by phathuynh27 Friday, March 27, 2015 8:00 PM
    Wednesday, March 25, 2015 11:13 PM
    Moderator
  • 'office|project|visio'

    is an OR condition.


    ¯\_(ツ)_/¯

    • Marked as answer by phathuynh27 Friday, March 27, 2015 8:00 PM
    Thursday, March 26, 2015 1:36 PM

All replies

  • psinfo -s \\computername | Select-String '(?!security)Office|Project|Visio'

    ¯\_(ツ)_/¯

    Wednesday, March 25, 2015 9:36 PM
  • Possibly more intuitive than Select-String:

    (psinfo -s \\computername) -match 'Office','Project','Visio' -notmatch 'security|update'


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    • Proposed as answer by FaustoNascimento Friday, March 27, 2015 10:10 AM
    • Marked as answer by phathuynh27 Friday, March 27, 2015 8:00 PM
    Wednesday, March 25, 2015 11:13 PM
    Moderator
  • Thanks JRV.  It appears the above is for apps that matches "Office" AND "project" AND "Visio".  How do I change it to get apps that matches "Office" or "Project" or "Visio"?  Also, is there a away for me to export the result to a csv format?  Thanks in advance.

    Thursday, March 26, 2015 1:24 PM
  • 'office|project|visio'

    is an OR condition.


    ¯\_(ツ)_/¯

    • Marked as answer by phathuynh27 Friday, March 27, 2015 8:00 PM
    Thursday, March 26, 2015 1:36 PM
  • Thanks so much, that worked.
    Thursday, March 26, 2015 2:02 PM
  • Hi,

    How do I exclusions (eg. Security or Update) using WMI?

    

    Get-WmiObject -Class Win32_Product -ComputerName $Computername | ? {$_.Name -like '*Office*' -or $_.Name -like '*Visio*' -or $_.Name -like '*Project*' } | Select-Object @{N="ComputerName";E={$Computername}},Vendor,Name

    Friday, March 27, 2015 8:00 PM
  • You can't just keep asking new questions. 

    help Get-WmiObject -full

    Use -Filter


    ¯\_(ツ)_/¯

    Friday, March 27, 2015 8:14 PM