Apologies for the basic question, I like to dabble in Powershell but as I don't use it frequently enough I have forgotten a lot!
I have a csv list of users' employee numbers (employee.csv), which are in AD under "extensionAttribute15"
I would like, for each employee number in the list, to return each accounts SamAccountName and what their AD group membership is, into an Excel sheet
So far I have
$employee = Import-csv .\Downloads\employee.csv
$employee | ForEach-Object {
Get-ADUser -Credential $Credentials -Filter "extensionAttribute15 -like '*$($_.extensionAttribute15)*'" -Properties * | Select-Object extensionAttribute15, Name, emailAddress, samAccountName, Description, MemberOf | Export-Csv .\Downloads\new_employee.csv
}
which works, but it doesn't expand on the AD Group membership...
Thanks in advance!
Consider how you want the results to appear. Should all the groups be in the same cell, separated by a new line? Separated by a delimiter? Each group is displayed in a new row/column?
Here's a basic way to display each group in the same cell, separated by a new line
Here's a link