none
Manipulating object values in a collection RRS feed

  • Question

  • I have the following collection,.....

         $group = a,b,c,d

    I am trying to access a group under an OU...... the users are under the following structure   

            OU

                sub level

                    a

                    b

                    c

    I have a GUI which I present difference level under OU in a combox box object and I build the query to access the users under that group...

    $GroupUsers=Get-ADGroupMember$DropDownGUsers.SelectedItem.ToString() |select-object@{Name=$DropDownGUsers.SelectedItem.ToString();Expression={$_.Name}}  

    this part works... I retrieve a list of users as

          $GroupUsers

                  sub level

                  a

                  b

                  c

    In order to iterate thru the collection, I try to build the following query

    I use the following code.....

       foreach ($group in $GroupsUsers)

       {

            $group | select -expand {$_.  "'" + $DropDownUsers.SelectedItem.ToString() + "'"}

       }

        The combox selection contains the group and the group contains embedded spaces.

          so after it gets interpret it should create the following statement

                      a,b,c | select -expand {$_.'sub level'} which will allow me to access every value and that value

    I will plug it TO get-ADUser -Filter 'Name -like _____' -Properties

    I can NOT build the statement dynamic... Any suggestions    

     


    michael john ocasio



    • Edited by mjocasio23 Thursday, June 23, 2016 11:10 AM
    Thursday, June 23, 2016 11:08 AM

Answers

  • cool but you are limited to one property only not multiple for example

         -expand one, two , three....


    michael john ocasio


    That is correct.  Expanding more than one makes no technical sense.

    \_(ツ)_/

    • Marked as answer by mjocasio23 Thursday, June 30, 2016 3:41 PM
    Thursday, June 30, 2016 2:33 PM

All replies

  • Start with this:

    $GroupUsers=Get-ADGroupMember $DropDownGUsers.SelectedItem |
    	select -expand Name 


    \_(ツ)_/

    Thursday, June 23, 2016 3:08 PM
  • The following is just meaningless.  What are you trying to do?

    foreach ($group in $GroupsUsers)
    
       {
    
            $group | select -expand {$_.  "'" + $DropDownUsers.SelectedItem.ToString() + "'"}
    
       }
    


    \_(ツ)_/

    Thursday, June 23, 2016 3:09 PM
  • cool but you are limited to one property only not multiple for example

         -expand one, two , three....


    michael john ocasio

    Thursday, June 30, 2016 2:17 PM
  • cool but you are limited to one property only not multiple for example

         -expand one, two , three....


    michael john ocasio


    That is correct.  Expanding more than one makes no technical sense.

    \_(ツ)_/

    • Marked as answer by mjocasio23 Thursday, June 30, 2016 3:41 PM
    Thursday, June 30, 2016 2:33 PM