Hi All,
First time I use this forum :-0, anyhow I have a problem that I cannot get done in powershell.
I try to export all users with a prefix and their connected groups, meaning sAMaccountname, ADgroupname.
Get-ADUser -Filter {sAMAccountName -like "xx*" -and enabled -eq $true} | select sAMAccountName | foreach-object {
Get-ADPrincipalGroupMembership $_.SamAccountName | select name}
This script just provides me the groupname of all group of the users stating with XX, could somebody help me to get the SamAccountName & The groupname as output to excel?
Many times thanks!
Greets,
Mathijs