Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How do I get Email Addreses of Group members?

$
0
0

Hi,

Using the command:  $a = Get-QADGroupMember $Group | select LogonName | Out-File "c:\temp\menu.txt"

I can get the logon names of the members of an AD group.

And using the command: $a = Get-QADUser -LogonName $item | select mail

$a.mail

I can get the EMail address of an AD User.

How do I take the out put of the first command and use that as an input for the second command so that I get a List of the Group members EMail addresse?

I tried this:

$TextFile = gc "c:\temp\menu.txt" | Sort-Object

foreach ($item in $TextFile) {
 Write-Host $item
 $a = Get-QADUser -LogonName $item | select mail }

But it does not like $item as a parameter.

Get-QADUser : The search filter is invalid.
At C:\Scripts\PS1\Get-GroupMembers.ps1:35 char:18
+     $a = Get-QADUser <<<<  -LogonName $item

TIA

OldDog


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>