I want to modify my ActiveDirectory lookup script to output a certain result in color.
The Script Imports the AD module and then prompts you to enter a username and see certain properties such as Name, E-mail Address and Employee ID.
There are a couple of properties whose color I'd like to change depending on the output.
For example if 'LockedOut' or 'PasswordExpired' is 'True', I would like the text color to be red for these particular results.
Is that possible? Any help is greatly appreciated!
Here is the script
Import-Module ActiveDirectory
do{
$username = (read-host "Please Enter Username to Lookup")
get-aduser $username -properties Created, Name, EmployeeID, EmailAddress, Enabled, LockedOut, LastBadPasswordAttempt, PasswordExpired, AccountExpires, LastLogonDate, Modified, LogonCount, HomeDirectory, Office, TelephoneNumber | Format-List Created, Modified, LogonCount, Name, EmailAddress, EmployeeID, Enabled, LockedOut, PasswordExpired, LastLogonDate, LastBadPasswordAttempt, HomeDirectory, Office, TelephoneNumber
$response = Read-Host "Enter 'Y' to check another user, any other key to exit"
Clear-Host
}
while ($response -eq "Y")