powershell assign one row from document to variable
-
16-06-2021 - |
Question
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
Solution
This show users with email using parameter of property you choose and wildcard:
Get-QADUser -Email * | select samaccountname, email
OTHER TIPS
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow