I'd like to do something like this, mainly for code readability:
$ADProperties = "extensionAttribute1,Department,Company,telephoneNumber"
$ADFilter = "{(objectClass -eq "user") -and (enabled -eq $True)}"
Get-ADUser -Filter $ADFilter -Properties $ADProperties
I get errors like: Get-Aduser : One or more properties are invalid.
Seems like I've seen a way to pass either the Filter or Properties somehow, but can't find it now.
EDIT - This works for -Properties
:
$ADProperties = "EmployeeID","EmployeeNumber","extensionAttribute1","Department"
(Thanks Eris) but this throws error:
$ADProperties = extensionAttribute1,Department,Company,telephoneNumber
Also, per Vasili, this works:
$str = @("foo","bar")
This works for -Filter
$ADFilter = {(objectClass -eq "user") -and (enabled -eq $True)}
Thanks everyone. MOB