Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. $Group = (Get-Content -Path C:UsersmyusernameDocumentstestlist.txt)
  2.  
  3. $Table = @()
  4.  
  5. $Record = [ordered] @{
  6. "Group Name" = ""
  7. "Name" = ""
  8. "Username" = ""
  9. }
  10.  
  11. foreach ($Group in $Groups)
  12. {
  13.  
  14. $Arrayofmembers = Get-ADGroupMember -Identity -Group|selectname,samaccountname
  15.  
  16. foreach ($Member in $Arrayofmembers)
  17. {
  18. $Record."Group Name" = $Group
  19. $Record."Name" = $Member.name
  20. $Record."Username" = $Member.samaccountname
  21. $objRecord = New-Object psobject -Property $Record
  22. $Table += $objrecord
  23.  
  24. }
  25.  
  26. }
  27.  
  28. $Table |export-csv "C:usersmyusernameDocumentssecuritygroups.csv" -NoTypeInformation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement