我想修改我的 ActiveDirectory 查找脚本以输出某个颜色的结果。
脚本导入 AD 模块,然后提示您输入用户名并查看某些属性,例如姓名、电子邮件地址和员工 ID。
我想根据输出更改几个属性的颜色。
例如,如果“LockedOut”或“PasswordExpired”为“True”,我希望这些特定结果的文本颜色为红色。
那可能吗?任何帮助是极大的赞赏!
这是脚本
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")