So I am trying to query a group in AD, then use that list to create a list of email addresses. I am using the below command:
Get-ADGroupMember mygroup -Server my.server.com | Select-Object SID | Get-ADUser -Identity $_.SID -Properties cn,mail -server my.server.com | Select-Object Samaccountname,mail | Format-Table Samaccountname,mail
when I run this I get the below error.
Get-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null or an element of the argument collection contains a null value.
At line:1 char:107
... User -Identity $_.SID -Properties cn,mail -server na.ko.com | Select-Object Sama ...
- CategoryInfo : InvalidData: (:) [Get-ADUser], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.GetADUser
Anyone feel like teaching a newb?
ForEach{Get-ADUser ....}
– TheMadTechnician