title: Powershell - expression in properties
body: <p>I don't know how to add expressions in property declaration.
  I created a script to get local admin members on servers and it works fine.
  Now i want to add another property which should check if user specified in &quot;Administrators&quot; property  is enabled or not, so i added property, &quot;User Enabled&quot; but it doesn't show anything</p>
  <pre><code>Foreach ($server in $servers){
  
   Try{
         $admins = Gwmi win32_groupuser –computer $server -Erroraction Stop
         $admins = $admins |? {$_.groupcomponent –like '*&quot;Administrators&quot;'}
         $admins = $admins |% { $_.partcomponent –match “.+Domain\=(.+)\,Name\=(.+)$” &gt; $nul 
         $matches[1].trim('&quot;') + “\” + $matches[2].trim('&quot;') | Where-Object {$_ -like &quot;$domain*&quot; -and $_ -notlike &quot;*Domain Admins*&quot;}}
         
        
  
          foreach ($admin in $admins){
             # remove domain name
             $username = $admin.Split('\')[1]
             # Create properties
             $administratorProperties = @{
             &quot;Administrators&quot; = $admin
             &quot;Local Admin type&quot; = &quot;Domain users&quot;
             &quot;Machine name&quot; = $server
              # check if local admin is enabled or not in AD
             Label =&quot;User Enabled&quot; ; expression = {(Get-AdUser -Filter &quot;SamAccountName -eq '$userName'&quot;).Enabled}  
  
             }
             $adm += New-Object psobject -Property $administratorProperties
          }
  
           $adm | Select &quot;Machine Name&quot;, &quot;Administrators&quot;, &quot;Local Admin type&quot;, &quot;User Enabled&quot; | Export-CSV &quot;C:\Temp\LOcalAdmins.CSV&quot; –NoTypeInformation
             
  
   }
   catch [Exception]
  {
      if ($_.Exception.GetType().Name -like &quot;*COMException*&quot;) {
           Write-Verbose -Message ('{0} is unreachable' -f $server) -Verbose
      }
      else{
           Write-Warning $Error[0]
      }
   }
  } 
    
  
  Machine name     : MACHINE
  Administrators   : DOMAIN\User1
  Label            : User Enabled
  Local Admin type : Domain users
  expression       : (Get-AdUser -Filter &quot;SamAccountName -eq '$userName'&quot;).Enabled
  </code></pre>
  <p>Is it possible to check if user in $username variable is enabled or not.</p>