-Question 1-
The script:
$ADInfo = (Get-ADUser $ntaccount1 -Properties *)
Write-Host -NoNewLine -ForegroundColor Gray "Enabled ";
Write-Host -NoNewLine ": ";
if ($ADInfo.Enabled -eq "False") {'Write-Host -ForegroundColor Gray $ADInfo.Enabled'} ELSE {'Write-Host -ForegroundColor Red $ADinfo.Enabled'}; #If False=gray if True=red
The output:
Enabled: False
I am trying to make it, so if $ADInfo.Enabled is equal to False, be one color. And if it is True, be another. I am having problems getting that to work.
-Question 2-
I am trying to get this script in the same format as question 1, however, I don't get the same output. What is pasted below works 100%. It results an expiration date from AD. If I try to turn it into question 1, I get some random date 12/31/1600 7:00:00 PM . I want it the same as question 1, in the result that I can make the output date any color I choose.
Get-ADUser -identity usernamehere -properties msDS-UserPasswordExpiryTimeComputed | format-list @{ Name = "Expiration Date";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}};