0

I'm using cmdlet Get-QADUser (by Quest software) to list domain users from Active Directory. The output is several hundreds of rows with domain names and email addresses. I need to select only those rows, where is email address and assign them to a separate variable.

This is part of $domain_names variable:

turbekova                                                   turbek@dock.com                                                       
senajova                                                    senaj@dock.com                                                       
mackova                                                                                                            
pukansky                                                    pukansky@dock.com                                                       
tiko                                                        tiko@dock.com                                                       
dvorska                                                                                                            
trescanska                                                  tresc@dock.com          

Thank you

culter
  • 5,487
  • 15
  • 54
  • 66

2 Answers2

2

You can filter with Where-Object:

$hasEmail = Get-QADUser | Where-Object { $_.Email }

Or whatever the column is named. You chose to not include the property names in your copied output.

Joey
  • 344,408
  • 85
  • 689
  • 683
2

This show users with email using parameter of property you choose and wildcard:

 Get-QADUser -Email * | select samaccountname, email
CB.
  • 58,865
  • 9
  • 159
  • 159
  • Thank you, Christian, this works excellently. But I have last question: Is it possible to check if the email addresses have e.g. 20 characters? I've tried it with Where-Object {$_.email.Count -eq 20}, but this isn't working.. – culter Jun 22 '12 at 14:51