SHARE
TWEET

Untitled

a guest Jun 18th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top