This is what I have but not fully to pull to info the way I want.
import-module activedirectory
$userlist = Get-Content 'c:\temp\AllUsersSamaccountname.txt'
Get-ADUser -Filter '*' -Properties memberof | ? {
$userlist -contains $_.SamAccountName} | % {
$username = $_
$groups = $_ | select -Expand memberof | % { (Get-ADGroup $_).Name }
"{0} {1}" -f $username, ($groups -join ', ')
} | Out-File 'c:\temp\AllUserinfo6.CSV'
The output come in this format...
Firstname, lastname, group1, group2, group3, group4
lastname, firstname, group1, group2, group3, group4
I need it like this....
Firstname, lastname, samaccountname, whencreated, group1, group2, group3, group4