title: Powershell - Output Color for certain results
body: <p>I am running the code below and it works. What I am trying to do is, in the results when Enabled properties is True I would like to the text 'True' foreground color to be green otherwise if 'false' color Red.</p>
  
  <p>The same with the Password never expires properties, if the result is 'True' I would like to the text 'True' foreground color to be Red otherwise if its 'False' color green.</p>
  
  <p>I am trying to fit an if-else statement into the code but have not been successfull.</p>
  
  <p>Code:</p>
  
  <pre><code>Get-ADUser "user name"  -Properties Enabled,LockedOut,DisplayName,GivenName, SurName,Mail,LastLogon, Created,passwordlastset,Passwordneverexpires,msDS-UserPasswordExpiryTimeComputed, Description, office, Canonicalname | `
          Select-Object Enabled, 
          @{Expression={$_.LockedOut};Label='Locked';}, 
          @{Expression={$_.DisplayName};Label='Display Name';},
          @{Expression ={$_.GivenName};Label='Name';}, `
          @{Expression ={$_.SurName}; Label='Last Name'; }, 
          Mail, 
          @{Expression ={[DateTime]::FromFileTime($_.LastLogon)}; Label='Last Logon';}, 
          @{Expression={$_.Created};Label='Date Created';}, 
          @{Expression={$_.passwordlastset};Label='PW Last Reset';}, 
          @{Expression={$_.Passwordneverexpires};Label='PW Never Expires';},
          @{Name="PW Exp Date";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}  ,
          Description, 
          Office,
          Canonicalname 
          Format-list
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Oiwsp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Oiwsp.jpg" alt="enter image description here"></a></p>
  
  <p>Any suggestions?</p>