I run the following against my client's AD... It produces what appears to be CSV.
$members=Get-ADGroupMember -Identity "my ad group" -Recursive | % {Get-ADUser -Identity $_.distinguishedName -Properties * | ? {$_.enabled -eq $true} | select-object emailaddress}
$members
emailaddress
------------
john.bob@org.com
pete.smith@org.com
however, trying search in this variable does not work so well. The best I can do is this
$members -like "@{emailaddress=john.bob@org.com}"
@{emailaddress=john.bob@org.com}
But I would like to do this:
$members -like "john.bob@org.com"
john.bob@org.com
I would like the initial command to produce a simpler array, so that the last '-like' syntax works. How to do this?