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