Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Group = (Get-Content -Path C:UsersmyusernameDocumentstestlist.txt)
- $Table = @()
- $Record = [ordered] @{
- "Group Name" = ""
- "Name" = ""
- "Username" = ""
- }
- foreach ($Group in $Groups)
- {
- $Arrayofmembers = Get-ADGroupMember -Identity -Group|selectname,samaccountname
- foreach ($Member in $Arrayofmembers)
- {
- $Record."Group Name" = $Group
- $Record."Name" = $Member.name
- $Record."Username" = $Member.samaccountname
- $objRecord = New-Object psobject -Property $Record
- $Table += $objrecord
- }
- }
- $Table |export-csv "C:usersmyusernameDocumentssecuritygroups.csv" -NoTypeInformation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement