none
Getting powershell sort to work RRS feed

  • Question

  • Hi, I’m just beginning with powershell. I’ve written a script to create a list of AD group members; but, I my attempts to sort the list have not succeeded. I’m trying to sort the members of each group separately. I could use some help please.

    $AD_list = Get-Content C:\SOX_Periodic_Review\Executables\list_of_AD_groups.txt

    foreach ($group in $AD_list) {

                    get-adgroupmember $group -recursive |

        Select @{N="Users";

             E={"$group,$($_.DistinguishedName.Split(',')[-3].Split('=')[1])\$($_.SamAccountName)"}} |

        Sort-object -property samaccountname}

    Tuesday, April 28, 2015 5:46 PM

Answers