jeudi 28 août 2014

Powershell color output


Vote count:

0




The script:



$ADInfo = Get-ADUser -identity $ntaccount1 -properties name, samaccountname, mail, enabled, passwordlastset, whencreated, whenchanged, employeeid, homephone, mobile, lastbadpasswordattempt, description, badlogoncount, badpwdcount, logoncount, lockedout, msDS-UserPasswordExpiryTimeComputed;

$ADInfo `
| Format-List `
@{ Name = "Full Name"; Expression = { $_.name } },
@{ Name = "User ID"; Expression = { $_.samaccountname } },
@{ Name = "Email"; Expression = { $_.mail } },
@{ Name = "Enabled"; Expression = { $_.enabled } },
@{ Name = "Locked Out"; Expression = { $_.LockedOut } },
@{Name="Expiration Date";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}},
@{ Name = "Password Last Set"; Expression = { $_.passwordlastset } },
@{ Name = "Last Bad Password Attempt"; Expression = { $_.lastbadpasswordattempt } },
@{ Name = "Account Creation Date"; Expression = { $_.whencreated } },
@{ Name = "Last change"; Expression = { $_.whenchanged } },
@{ Name = "Employee ID"; Expression = { $_.employeeid } },
#@{ Name = "Home Phone #"; Expression = { $_.homephone } },
#@{ Name = "Mobile Phone #"; Expression = { $_.mobile } },
@{ Name = "Account Description"; Expression = { $_.description } }; #Ends here
#@{ Name = "Bad Logon Count"; Expression = { $_.badlogoncount } },
#@{ Name = "Bad Password Count"; Expression = { $_.badpwdcount } },
#@{ Name = "Logon Count"; Expression = { $_.logoncount } };


The output:



Full Name : Admin
User ID : Admin
Email :
Enabled : True
Locked Out : False
Expiration Date : 12/31/1600 7:00:00 PM
Password Last Set :
Last Bad Password Attempt : 8/26/2014 10:11:08 PM
Account Creation Date : 12/8/2011 2:45:17 AM
Last change : 8/21/2014 8:26:12 AM
Employee ID :
Account Description : Auto-Generated


I did some searching but am unable to find an answer. Is it possible to colorcode parts of the output? For example...making "User ID" red and the output "Admin" for that, green?



asked 1 min ago

Aaron

364






Powershell color output

Aucun commentaire:

Enregistrer un commentaire