I am looking for a way to change the current output of the following command so it's easier to read.
$list= get-content "c:\userlist.txt"
Foreach ($user in $list)
{
Write-Host $user
Get-ADPrincipalGroupMembership $user |select name |Where-Object {$_.name -like "*admin*"}
write-host " "
}
Current output is as follows:
user1
name
----
admin1
admin2
user2
admin3
admin4
I would like it to be displayed like the below or something similar without the name title and extra line breaks. Thanks!
User1
admin1
admin2
User2
admin3
admin4