Advertisement
naveenk232

GroupMem

Feb 9th, 2012
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Could you please help me ?
  2.  
  3. Is it possible to get results like this - actually I want to compare to oracle user _id group file
  4.  
  5. DN        SamAccountName    Groups
  6. abc.com   user1             group1;group2;group3
  7.  
  8. How to export the above results in columns, like :
  9.  
  10. DN       SamAccountName  Groups
  11. abc.com  user1           group1
  12.          user1           group2
  13.          user1           group3
  14.  
  15.  
  16. =================================================
  17.  
  18. I asked this question - and got below reply thank to Andy but I am getting memory error since there are more than 20000 users.
  19.  
  20. $users = Get-QADUser -searchRoot $OuDomain -SizeLimit 0
  21. $users | Sort-Object SamAccountName | % {
  22.     $user = $_ | Select-Object dn, sAMAccountName
  23.     if ($lastDomain -eq $user.dn) {
  24.         $lastDomain = ""
  25.     } else {
  26.         $lastDomain = $user.dn
  27.     }
  28.     $groups = Get-QADMemberOf $_ | Select-Object -expandProperty Name
  29.     $groups | % {
  30.         $user2 = New-Object -TypeName PsObject -Property @{
  31.                 "Domain" = $lastDomain
  32.                 "sAMAccountName" = $user.sAMAccountName
  33.                 "Group" = $_
  34.             }
  35.         $user2
  36.     }
  37. } | export-csv $FilePath
  38.  
  39.  
  40.  
  41.  
  42.  
  43. Rgards
  44. Naveen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement