Filtering out results from multiple objects in powershell?

Author Message
sdm44990

  • Total Posts : 18
  • Scores: 0
  • Reward points : 0
  • Joined: 1/26/2007
  • Status: offline
Filtering out results from multiple objects in powershell? Friday, November 19, 2010 3:37 AM (permalink)
0

Is there a way to run a regular expression for multiple objects, so multiple objects and their output filter out the results
without having to perform an Out-String first?  I was wanting to run a regex with numerous users and groups, and their standard file system rights by default and
then query against any non standard perms for various directories.  However I have found that it appears to be a little bit more difficult, but can export out to a
string value, however, I'll be grabbing those results (hopefully after the filter) and exporting to CSV, so would be much easier/cleaner to filter out right after
the Select-Object statement, does anyone have any suggestions to do that?
So example:
Example:
Get-Item "C:\temp" | Get-Acl | % {$_.Access} | Select-Object IdentityReference,FileSystemRights | ? {$_ -notmatch "Administrators"}
IdentityReference                                                                                      FileSystemRights
-----------------                                                                                      ----------------
NT AUTHORITY\SYSTEM                                                                                         FullControl
BUILTIN\Administrators                                                                                      FullControl
BUILTIN\Users                                                                               ReadAndExecute, Synchronize
BUILTIN\Users                                                                                                AppendData
BUILTIN\Users                                                                                               CreateFiles
CREATOR OWNER                                                                                                 268435456

But regex would be great to get the values like "Administrators\S*\s*FullControl" that would filter out both IdentityReference and FileSystemRights based on the regex.
 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    Re:Filtering out results from multiple objects in powershell? Friday, November 19, 2010 3:55 AM (permalink)
    0
    I'm not sure that I understand. The -match and -notmatch operators support regular expressions.
     
    Get-Help About_comparison_operators
    "... 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
     
    #2
      sdm44990

      • Total Posts : 18
      • Scores: 0
      • Reward points : 0
      • Joined: 1/26/2007
      • Status: offline
      Re:Filtering out results from multiple objects in powershell? Friday, November 19, 2010 4:17 AM (permalink)
      0
      Yes, but when you output the select-objects such as above with IdentityReference and FileSystemRights, each object is seperate so a regex doesn't query both values without exporting to a string value etc.
       
      #3
        sdm44990

        • Total Posts : 18
        • Scores: 0
        • Reward points : 0
        • Joined: 1/26/2007
        • Status: offline
        Re:Filtering out results from multiple objects in powershell? Friday, November 19, 2010 4:23 AM (permalink)
        0
        So for example:
        Get-Item "C:\temp" | Get-Acl | % {$_.Access} | Select-Object IdentityReference,FileSystemRights | ? {$_.IdentityReference  -Notmatch "Administrators\S*\s*FullControl"}
        IdentityReference                                                                                      FileSystemRights
        -----------------                                                                                      ----------------
        NT AUTHORITY\SYSTEM                                                                                         FullControl
        BUILTIN\Administrators                                                                                      FullControl
        BUILTIN\Users                                                                               ReadAndExecute, Synchronize
        BUILTIN\Users                                                                                                AppendData
        BUILTIN\Users                                                                                               CreateFiles
        * doens't catch FullControl
         
        Get-Item "C:\temp" | Get-Acl | % {$_.Access} | Select-Object IdentityReference,FileSystemRights | ? {$_.IdentityReference  -Notmatch "Administrators"}
        *filters out administrators, but not based on FileSystemRights, only on IdentityReference.
        IdentityReference                                                                                      FileSystemRights
        -----------------                                                                                      ----------------
        NT AUTHORITY\SYSTEM                                                                                         FullControl
        BUILTIN\Users                                                                               ReadAndExecute, Synchronize
        BUILTIN\Users                                                                                                AppendData
        BUILTIN\Users                                                                                               CreateFiles
         
        #4
          sdm44990

          • Total Posts : 18
          • Scores: 0
          • Reward points : 0
          • Joined: 1/26/2007
          • Status: offline
          Re:Filtering out results from multiple objects in powershell? Saturday, November 20, 2010 6:46 AM (permalink)
          0
          Thanks for the help found the answer.
           
          #5
            anytua34i

            • Total Posts : 9
            • Scores: 0
            • Reward points : 0
            • Joined: 1/24/2011
            • Status: offline
            Re:Filtering out results from multiple objects in powershell? Monday, January 24, 2011 7:07 PM (permalink)
            0
            giving 7 hem a whole new feeling new york asian escort about themselves. Another aspect of stress management involves making changes in your life to new york asian escorts help you reduce the events that trigger your episodes. In some cases thi new york escort may be a simple matter of gettin new york escorts out more often or it can mean changing jobs or careers
             
            #6

              Online Bookmarks Sharing: Share/Bookmark

              Jump to:

              Current active users

              There are 0 members and 1 guests.

              Icon Legend and Permission

              • 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
              • Read Message
              • Post New Thread
              • Reply to message
              • Post New Poll
              • Submit Vote
              • Post reward post
              • Delete my own posts
              • Delete my own threads
              • Rate post

              2000-2012 ASPPlayground.NET Forum Version 3.9