{"id":65,"date":"2018-02-12T15:11:59","date_gmt":"2018-02-12T15:11:59","guid":{"rendered":"https:\/\/www.atlanta247.com\/blog\/?p=65"},"modified":"2019-01-11T21:34:45","modified_gmt":"2019-01-11T21:34:45","slug":"a-list-of-user-info","status":"publish","type":"post","link":"https:\/\/www.atlanta247.com\/blog\/2018\/02\/12\/a-list-of-user-info\/","title":{"rendered":"A list of user info.."},"content":{"rendered":"<p>One of the things we commonly need is a list of user info.  Putting that together in code is easy &#8211; but if we want a nice output to send to users? This does that. <\/p>\n<p><code><\/p>\n<p>$InputSAM = \"SAMACCOUNTNAME\"<\/p>\n<p>############################<br \/>\n##<br \/>\n## Get user object<br \/>\n##<br \/>\n############################<br \/>\n$ObjUser = Get-ADUser -Identity $InputSAM -Properties *<\/p>\n<p>############################<br \/>\n##<br \/>\n##  Get user's manager Object<br \/>\n##<br \/>\n############################<\/p>\n<p>$UserManager = $ObjUser.Manager<br \/>\n$ObjUserManager = Get-ADUser -Identity $UserManager -Properties OfficePhone,title<\/p>\n<p>############################<br \/>\n##<br \/>\n##  Zig the Zagged Data<br \/>\n##<br \/>\n############################<\/p>\n<p>$DCS = Get-ADDomainController -Filter *<br \/>\n$NOW = Get-Date<\/p>\n<p>#######################################<br \/>\n##<br \/>\n## HTML Stuff<br \/>\n##<br \/>\n######################################<br \/>\n$Goodgreen = \"LimeGreen\"<br \/>\n$name = $ObjUser.DisplayName<\/p>\n<p># TABLE<\/p>\n<p>$tableHeader = \"<Table border =0 Width = 100%><Caption><strong>User Information for: <\/strong>\" + $name + \"<\/Caption>\"<br \/>\n$tableEnd = \"<\/table>\n<p><Table border =0 Width = 100%>\"<br \/>\n$line = \"<\/p>\n<tr>\n<td width=100% style=`\"height:10px;`\" colspan=4><HR><\/strong><\/font><\/td>\n<p>\"<br \/>\n$TableRow = \"<\/p>\n<tr>\"<\/p>\n<p># Cell <\/p>\n<p>$CellStart = \"<\/p>\n<td width=22% bgcolor=`\"\"\n$cellMiddle1 = \"`\" align=`\"right`\"><font face=`\"Verdana`\"size=2 color=`\"Black`\"><strong>\"<br \/>\n$Cellmiddle2 = \"<\/strong><\/font><\/td>\n<td colspan=4><font face=`\"Verdana`\" size=2>\"<br \/>\n$cellend = \"<\/strong><\/font><\/td>\n<p>\"<br \/>\n$defaultcolorCell = $TableBody + $CellStart + $Goodgreen + $cellMiddle1<\/p>\n<p>### example<br \/>\n# $DistinguishedNameTitle = \"Distinguished Name:\"<br \/>\n# $DistinguishedNameColor = $Goodgreen<br \/>\n# $DistinguishedNamedata = $DistinguishedName<br \/>\n# $DistinguishedNameCells = $CellStart + $DistinguishedNameColor + $cellMiddle1 + $DistinguishedNameTitle + $Cellmiddle2 + $DistinguishedNamedata + $cellend<\/p>\n<p># $TableBody = $TableBody + $CellStart + $DistinguishedNameColor + $cellMiddle1 + $DistinguishedNameTitle + $Cellmiddle2 + $DistinguishedNamedata + $cellend<\/p>\n<p>############################<br \/>\n##<br \/>\n##  Data to return<br \/>\n##<br \/>\n############################<\/p>\n<p># start our Table body with a new line and a row<\/p>\n<p>[string]$TableBody = $line + $TableRow<\/p>\n<p>##################################################<br \/>\n# Who info<\/p>\n<p>$name = $ObjUser.DisplayName<br \/>\n$nametitle = \"Display Name: \"<br \/>\n$namedata = $ObjUser.DisplayName<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $NameTitle + $Cellmiddle2 + $Namedata + $cellend<\/p>\n<p>$UserSAM = $objuser.SamAccountName<br \/>\n$UserSAMtitle = \"Login: \"<br \/>\n$UserSAMdata = $UserSAM<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $UserSAMtitle + $Cellmiddle2 + $UserSAMdata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$title = $objuser.Title<br \/>\n$titletitle = \"Title: \"<br \/>\n$titledata = $title<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $titletitle + $Cellmiddle2 + $titledata + $cellend<\/p>\n<p>$Description = $ObjUser.Description<br \/>\n$Descriptiontitle = \"Prefered Title: \"<br \/>\n$Descriptiondata = $Description<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $Descriptiontitle + $Cellmiddle2 + $Descriptiondata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$employeedepartment = $ObjUser.Department<br \/>\n$employeedepartmenttitle = \"Department: \"<br \/>\n$employeedepartmentdata = $employeedepartment<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $employeedepartmenttitle + $Cellmiddle2 + $employeedepartmentdata + $cellend<\/p>\n<p>$Company = $ObjUser.Company<br \/>\n$Companytitle = \"Company: \"<br \/>\n$Companydata = $Company<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $Companytitle + $Cellmiddle2 + $Companydata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$DistinguishedName = $ObjUser.DistinguishedName<br \/>\n$DistinguishedNameTitle = \"Distinguished Name: \"<br \/>\n$DistinguishedNamedata = $ObjUser.DistinguishedName<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $DistinguishedNameTitle + $Cellmiddle2 + $DistinguishedNamedata + $cellend<\/p>\n<p>##################################################<br \/>\n# Employee Details<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#Section header<br \/>\n$TableBody = $TableBody + \"<\/p>\n<tr>\n<td width=100% style=`\"height:10px;`\" colspan=4>EMPLOYEE DETAILS<\/strong><\/font><\/td>\n<p>\"<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$officephone = $objuser.OfficePhone<br \/>\n$officephonetitle = \"Office Phone: \"<br \/>\n$officephonedata = $officephone<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $officephonetitle + $Cellmiddle2 + $officephonedata + $cellend<\/p>\n<p>$homephone = $ObjUser.HomePhone<br \/>\n$homephonetitle = \"Home or Cell: \"<br \/>\n$homephonedata = $homephone<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $homephonetitle + $Cellmiddle2 + $homephonedata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$employeeID = $objuser.EmployeeID<br \/>\n$employeeIDtitle = \"Employee ID: \"<br \/>\n$employeeIDdata = $employeeID<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $employeeIDtitle + $Cellmiddle2 + $employeeIDdata + $cellend<\/p>\n<p>$employeetype = $ObjUser.employeeType<br \/>\n$employeetypetitle = \"Account Type: \"<br \/>\n$employeetypedata = $employeetype<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $employeetypetitle + $Cellmiddle2 + $employeetypedata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$location = $ObjUser.Office<br \/>\n$locationtitle = \"Office: \"<br \/>\n$locationdata = $location<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $locationtitle + $Cellmiddle2 + $locationdata + $cellend<\/p>\n<p>$email = $ObjUser.EmailAddress<br \/>\n$emailtitle = \"Email: \"<br \/>\n$emaildata = $email<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $emailtitle + $Cellmiddle2 + $emaildata + $cellend<\/p>\n<p>###########################################<br \/>\n###<br \/>\n###  We need to pause and Get the multi DC stuff<br \/>\n###<br \/>\n##############################################<\/p>\n<p>  $LastLogintime = 0<br \/>\n  $DefenderLastLogintime = 0<br \/>\n  $DCLastFailedLogintime = 0<br \/>\n  $BadLogins = 0<br \/>\n  $accountchangedtime = 0<\/p>\n<p>  foreach($dc in $dcs)<br \/>\n  {<br \/>\n    $hostname = $dc.HostName<br \/>\n    $LocalDCuser = Get-ADUser $UserSAM -Server $hostname | Get-ADObject -Properties * <\/p>\n<p>\tif($LocalDCuser.'defender-lastLogon' -gt $DefenderLastLogintime)<br \/>\n    \t{<br \/>\n    \t$DefenderLastLogintime = $LocalDCuser.'defender-lastLogon'<br \/>\n    \t}<br \/>\n\tif($LocalDCuser.LastLogon -gt $LastLogintime)<br \/>\n    \t{<br \/>\n    \t$LastLogintime = $LocalDCuser.LastLogon<br \/>\n    \t}<br \/>\n\tif($LocalDCuser.BadPasswordTime -gt $DCLastFailedLogintime)<br \/>\n    \t{<br \/>\n    \t$DCLastFailedLogintime = $LocalDCuser.BadPasswordTime<br \/>\n    \t}<\/p>\n<p>\tif($LocalDCuser.whenChanged -gt $accountchangedtime)<br \/>\n    \t{<br \/>\n    \t$accountchangedtime = $LocalDCuser.whenChanged<br \/>\n    \t}<\/p>\n<p>\tif($LocalDCuser.BadLogonCount -gt $BadLogins)<br \/>\n    \t{<br \/>\n    \t[string]$BadLogins = $LocalDCuser.BadLogonCount<br \/>\n    \t}<br \/>\n  }<br \/>\n  $LastSuccessfulLogin = [DateTime]::FromFileTime($LastLogintime)<br \/>\n  $DefenderLastSuccessfulLogin = [DateTime]::FromFileTime($DefenderLastLogintime)<br \/>\n  $lastfailedlogin = [DateTime]::FromFileTime($DCLastFailedLogintime)<br \/>\n  $Acctchanged = $accountchangedtime<\/p>\n<p>#  Echo $username<br \/>\n#  Echo \"last logged on at: \" $LastSuccessfulLogin<br \/>\n#  Echo \"last logged on with Defender token at: \" $DefenderLastSuccessfulLogin<br \/>\n#  Echo \"last FAILED log on at: \" $lastfailedlogin<br \/>\n#  Echo \"Recent Bad Logins: \" $BadLogins<br \/>\n#  <\/p>\n<p>###################################################<br \/>\n# Oddball Account Properties<br \/>\n#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$AcctCreated = $ObjUser.whenCreated<br \/>\n$AcctCreatedtitle = \"Account Creation Date: \"<br \/>\n$AcctCreateddata = $ObjUser.whenCreated<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $AcctCreatedtitle + $Cellmiddle2 + $AcctCreateddata + $cellend<\/p>\n<p>$Acctchangedtitle = \"Account Last Changed: \"<br \/>\n$Acctchangeddata = $Acctchanged<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $Acctchangedtitle + $Cellmiddle2 + $Acctchangeddata + $cellend<\/p>\n<p>###################################################<br \/>\n# Login times and Status<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#Section header<br \/>\n$TableBody = $TableBody + \"<\/p>\n<tr>\n<td width=100% style=`\"height:10px;`\" colspan=4>LOGIN DATES<\/strong><\/font><\/td>\n<p>\"<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$LastSuccessfulLogintitle = \"Last Successful Login: \"<br \/>\n$LastSuccessfulLogindata = $LastSuccessfulLogin<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $LastSuccessfulLogintitle + $Cellmiddle2 + $LastSuccessfulLogindata + $cellend<\/p>\n<p>$DefenderLastSuccessfulLogintitle = \"Last Defender Token Login: \"<br \/>\n$DefenderLastSuccessfulLogindata = $DefenderLastSuccessfulLogin<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $DefenderLastSuccessfulLogintitle + $Cellmiddle2 + $DefenderLastSuccessfulLogindata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$lastfailedlogintitle = \"Last Failed Login: \"<br \/>\n$lastfailedlogindata = $lastfailedlogin<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $lastfailedlogintitle + $Cellmiddle2 + $lastfailedlogindata + $cellend<\/p>\n<p>################################################################<br \/>\n## account status<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#Section header<br \/>\n$TableBody = $TableBody + \"<\/p>\n<tr>\n<td width=100% style=`\"height:10px;`\" colspan=4>ACCOUNT STATUS<\/strong><\/font><\/td>\n<p>\"<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>########## Account locked processing<br \/>\n$AcctLocked = $ObjUser.LockedOut<br \/>\nswitch($AcctLocked)<br \/>\n\t{<br \/>\n\tTrue<br \/>\n\t\t{<br \/>\n\t\t$AccountLockedColor = \"Red\"<br \/>\n\t\t}<br \/>\n\tFalse<br \/>\n\t\t{<br \/>\n\t\t$AccountLockedColor = \"LimeGreen\"<br \/>\n\t\t}<br \/>\n\t}<\/p>\n<p>$AcctLockedtitle = \"Account Locked: \"<br \/>\n$AcctLockeddata = $AcctLocked<br \/>\n$TableBody = $TableBody + $CellStart + $AccountLockedColor + $cellMiddle1 + $AcctLockedtitle + $Cellmiddle2 + $AcctLockeddata + $cellend<\/p>\n<p>######### account control processing<\/p>\n<p>$AccountControl = $ObjUser.userAccountControl<br \/>\nswitch($AccountControl)<br \/>\n\t{<br \/>\n\t512<br \/>\n\t\t{<br \/>\n\t\t$accountDisabled = \"False\"<br \/>\n\t\t$accountDisabledColor = \"LimeGreen\"<br \/>\n\t\t$passwordexpires = \"True\"<br \/>\n\t\t$passwordexpirescolor = \"LimeGreen\"<br \/>\n\t\t}<br \/>\n\t514<br \/>\n\t\t{<br \/>\n\t\t$accountDisabled = \"True\"<br \/>\n\t\t$accountDisabledColor = \"Red\"<br \/>\n\t\t$passwordexpires = \"True\"<br \/>\n\t\t$passwordexpirescolor = \"LimeGreen\"<br \/>\n\t\t}<br \/>\n\t66048<br \/>\n\t\t{<br \/>\n\t\t$accountDisabled = \"False\"<br \/>\n\t\t$accountDisabledColor = \"LimeGreen\"<br \/>\n\t\t$passwordexpires = \"false\"<br \/>\n\t\t$passwordexpirescolor = \"DarkOrange\"<br \/>\n\t\t}<br \/>\n\t66050<br \/>\n\t\t{<br \/>\n\t\t$accountDisabled = \"True\"<br \/>\n\t\t$accountDisabledColor = \"Red\"<br \/>\n\t\t$passwordexpires = \"false\"<br \/>\n\t\t$passwordexpirescolor = \"DarkOrange\"<br \/>\n\t\t}<br \/>\n\t}<\/p>\n<p>$accountDisabledtitle = \"Account Disabled: \"<br \/>\n$accountDisableddata = $accountDisabled<br \/>\n$TableBody = $TableBody + $CellStart + $accountDisabledColor + $cellMiddle1 + $accountDisabledtitle + $Cellmiddle2 + $accountDisableddata + $cellend<\/p>\n<p>################################################################<br \/>\n## password status<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#Section header<br \/>\n$TableBody = $TableBody + \"<\/p>\n<tr>\n<td width=100% style=`\"height:10px;`\" colspan=4>PASSWORD INFORMATION<\/strong><\/font><\/td>\n<p>\"<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$pwdlastChanged = $ObjUser.PasswordLastSet<br \/>\n$pwdlastChangedtitle = \"Password Last Set: \"<br \/>\n$pwdlastChangeddata = $pwdlastChanged<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $pwdlastChangedtitle + $Cellmiddle2 + $pwdlastChangeddata + $cellend<\/p>\n<p>########## password age calculation<br \/>\n$PwdAge = ($NOW - $pwdlastChanged).days<\/p>\n<p>switch($PwdAge)<br \/>\n\t{<br \/>\n \t{$_ -ge 0 -and $_ -le 45}<br \/>\n\t\t{<br \/>\n\t\t$PwdAgeColor = \"LimeGreen\"<br \/>\n\t\t}<br \/>\n\t{$_ -ge 46 -and $_ -le 55}<br \/>\n\t\t{<br \/>\n\t\t$PwdAgeColor = \"Yellow\"<br \/>\n\t\t}<br \/>\n \t{$_ -ge 56 -and $_ -le 60}<br \/>\n\t\t{<br \/>\n\t\t$PwdAgeColor = \"DarkOrange\"<br \/>\n\t\t}<br \/>\n \t{$_ -ge 61}<br \/>\n\t\t{<br \/>\n\t\t$PwdAgeColor = \"Red\"<br \/>\n\t\t}<br \/>\n \t}<\/p>\n<p>$PwdAgetitle = \"Password Age: \"<br \/>\n$PwdAgedata = $PwdAge<br \/>\n$TableBody = $TableBody + $CellStart + $PwdAgeColor + $cellMiddle1 + $PwdAgetitle + $Cellmiddle2 + $PwdAgedata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$passwordexpirestitle = \"Password Expires Policy: \"<br \/>\n$passwordexpiresdata = $passwordexpires<br \/>\n$TableBody = $TableBody + $CellStart + $passwordexpiresColor + $cellMiddle1 + $passwordexpirestitle + $Cellmiddle2 + $passwordexpiresdata + $cellend<\/p>\n<p>$PwdExpired = $ObjUser.PasswordExpired<br \/>\nswitch($PwdExpired)<br \/>\n\t{<br \/>\n\tFalse<br \/>\n\t\t{<br \/>\n\t\t$pwdExpiredColor = \"LimeGreen\"<br \/>\n\t\t}<br \/>\n\tTrue<br \/>\n\t\t{<br \/>\n\t\t$pwdExpiredColor = \"Red\"<br \/>\n\t\t}<br \/>\n\t}<\/p>\n<p>$PwdExpiredtitle = \"Password Expired?: \"<br \/>\n$PwdExpireddata = $PwdExpired<br \/>\n$TableBody = $TableBody + $CellStart + $PwdExpiredColor + $cellMiddle1 + $PwdExpiredtitle + $Cellmiddle2 + $PwdExpireddata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$UserchangePwd = $ObjUser.CannotChangePassword <\/p>\n<p>switch($UserchangePwd)<br \/>\n\t{<br \/>\n\tFalse<br \/>\n\t\t{<br \/>\n\t\t$UserChangepwdColor = \"LimeGreen\"<br \/>\n\t\t$UserchangePwdStatus = \"Yes\"<br \/>\n\t\t}<br \/>\n\tTrue<br \/>\n\t\t{<br \/>\n\t\t$UserChangepwdColor = \"Yellow\"<br \/>\n\t\t$UserchangePwdStatus = \"No\"<br \/>\n\t\t}<br \/>\n\t}<\/p>\n<p>$UserchangePwdtitle = \"User can change password?: \"<br \/>\n$UserchangePwddata = $UserchangePwdStatus<br \/>\n$TableBody = $TableBody + $CellStart + $UserchangePwdColor + $cellMiddle1 + $UserchangePwdtitle + $Cellmiddle2 + $UserchangePwddata + $cellend<\/p>\n<p># Domain Password Policy stuff<br \/>\n$ADDomainPasswordPolicy = Get-ADDefaultDomainPasswordPolicy<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>[string]$maxattempts = $ADDomainPasswordPolicy.LockoutThreshold<br \/>\n[string]$Remainingattempts = $maxattempts - $BadLogins<\/p>\n<p>$maxattemptstitle = \"Max\/Remaining Password Attempts: \"<br \/>\n[string]$maxattemptsdata = $maxattempts + \" \/ \" + $Remainingattempts<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $maxattemptstitle + $Cellmiddle2 + $maxattemptsdata + $cellend<\/p>\n<p>########## calculate account unlock policy<br \/>\n$LockoutDuration = $ADDomainPasswordPolicy.LockoutDuration<br \/>\nif ($LockoutDuration -le 0)<br \/>\n\t{<br \/>\n\t$Autounlock = \"Manual Unlock Only\"<br \/>\n\t}<br \/>\nif ($LockoutDuration -gt 0)<br \/>\n\t{<br \/>\n\t$Autounlock = \"[Days:Hours:Minutes] \" + $LockoutDuration<br \/>\n\t}<\/p>\n<p>$Autounlocktitle = \"Auto Unlock Duration: \"<br \/>\n$Autounlockdata = $Autounlock<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $Autounlocktitle + $Cellmiddle2 + $Autounlockdata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$MinPwdlength = $ADDomainPasswordPolicy.MinPasswordLength<br \/>\n$MinPwdlengthtitle = \"Minimum Password Length: \"<br \/>\n$MinPwdlengthdata = $MinPwdlength<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $MinPwdlengthtitle + $Cellmiddle2 + $MinPwdlengthdata + $cellend<\/p>\n<p>$MinPwdHistory = $ADDomainPasswordPolicy.PasswordHistoryCount<br \/>\n$MinPwdHistorytitle = \"Minimum Password History: \"<br \/>\n$MinPwdHistorydata = $MinPwdHistory<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $MinPwdHistorytitle + $Cellmiddle2 + $MinPwdHistorydata + $cellend<\/p>\n<p>################################################################<br \/>\n##  Profile Information<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#Section header<br \/>\n$TableBody = $TableBody + \"<\/p>\n<tr>\n<td width=100% style=`\"height:10px;`\" colspan=4>PROFILE INFORMATION<\/strong><\/font><\/td>\n<p>\"<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$Script = $ObjUser.ScriptPath<br \/>\n$Scripttitle = \"Login Script: \"<br \/>\n$Scriptdata = $Script<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $Scripttitle + $Cellmiddle2 + $Scriptdata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$homeLocation = $ObjUser.l<br \/>\n$HomeDirectory = \"\\\\microsoft.com\\user\\\" + $homeLocation + \"\\\" + $UserSAM + \"\\\"<br \/>\n$HomeDirectorytitle = \"Home Drive: \"<br \/>\n$HomeDirectorydata = $HomeDirectory<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $HomeDirectorytitle + $Cellmiddle2 + $HomeDirectorydata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$CitrixProfile = \"\\\\micosoft.com\\citrix\\Profiles\\TS\\\" + $UserSAM +\"<BR>\" + \"\\\\microsoft.com\\citrix\\Profiles\\TS-x64\\\" + $UserSAM<br \/>\n$CitrixProfiletitle = \"Citrix Profiles: \"<br \/>\n$CitrixProfiledata = $CitrixProfile<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $CitrixProfiletitle + $Cellmiddle2 + $CitrixProfiledata + $cellend<\/p>\n<p>################################################################<br \/>\n##  Exchange information<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#Section header<br \/>\n$TableBody = $TableBody + \"<\/p>\n<tr>\n<td width=100% style=`\"height:10px;`\" colspan=4>EXCHANGE INFORMATION<\/strong><\/font><\/td>\n<p>\"<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$ExchangeAccount = $ObjUser.msExchWhenMailboxCreated<br \/>\n$ExchangeAccounttitle = \"Mailbox Created: \"<br \/>\n$ExchangeAccountdata = $ExchangeAccount<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $ExchangeAccounttitle + $Cellmiddle2 + $ExchangeAccountdata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$proxyaddresses = $ObjUser.proxyAddresses<\/p>\n<p>Foreach ($mailitem in $proxyaddresses)<br \/>\n\t{<br \/>\n\t$mailitemlist = $mailitemlist + \"<br \/>\" + $mailitem<br \/>\n\t}<\/p>\n<p>$proxyaddressestitle = \"Messaging Addresses: \"<br \/>\n$proxyaddressesdata = $mailitemlist<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $proxyaddressestitle + $Cellmiddle2 + $proxyaddressesdata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$AssignedDelegates = $ObjUser.publicDelegatesBL<\/p>\n<p>Foreach ($mailbox in $AssignedDelegates)<br \/>\n\t{<br \/>\n\t$objmailbox = Get-ADUser -Identity $mailbox<br \/>\n\t$mailboxname = $objmailbox.name<br \/>\n\t$Publicmailbox = $publicmailbox + \"<br \/>\" + $mailboxname<br \/>\n\t}<\/p>\n<p>$AssignedDelegatestitle = \"Assigned Delegates: \"<br \/>\n$AssignedDelegatesdata = $Publicmailbox<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $AssignedDelegatestitle + $Cellmiddle2 + $AssignedDelegatesdata + $cellend<\/p>\n<p>$mailboxmanager = $ObjUser.msExchDelegateListBL<\/p>\n<p>Foreach ($mailbox in $mailboxmanager)<br \/>\n\t{<br \/>\n\t$objmailbox = Get-ADUser -Identity $mailbox<br \/>\n\t$mailboxname = $objmailbox.name<br \/>\n\t$mailboxlist =  $mailboxlist + \"<br \/>\" + $mailboxname<br \/>\n\t}<\/p>\n<p>$mailboxmanagertitle = \"Delegate Access: \"<br \/>\n$mailboxmanagerdata = $mailboxlist<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $mailboxmanagertitle + $Cellmiddle2 + $mailboxmanagerdata + $cellend<\/p>\n<p>############################<br \/>\n##<br \/>\n## Managers Data to return<br \/>\n##<br \/>\n############################<\/p>\n<p>################################################################<br \/>\n##  Manager information<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#Section header<br \/>\n$TableBody = $TableBody + \"<\/p>\n<tr>\n<td width=100% style=`\"height:10px;`\" colspan=4>LINE MANAGER<\/strong><\/font><\/td>\n<p>\"<\/p>\n<p>#new Line<br \/>\n$TableBody = $TableBody + $line<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$manager = $ObjUserManager.Name<br \/>\n$managertitle = \"Manager Name: \"<br \/>\n$managerdata = $manager<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $managertitle + $Cellmiddle2 + $managerdata + $cellend<\/p>\n<p>#new Row<br \/>\n$TableBody = $TableBody + $TableRow<\/p>\n<p>$managertitle = $ObjUserManager.title<br \/>\n$managertitletitle = \"Manager Title: \"<br \/>\n$managertitledata = $managertitle<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $managertitletitle + $Cellmiddle2 + $managertitledata + $cellend<\/p>\n<p>$managerphone = $ObjUserManager.OfficePhone<br \/>\n$managerphonetitle = \"Manager Office Phone: \"<br \/>\n$managerphonedata = $managerphone<br \/>\n$TableBody = $TableBody + $defaultcolorCell + $managerphonetitle + $Cellmiddle2 + $managerphonedata + $cellend<\/p>\n<p>###################################<br \/>\n##<br \/>\n##  Message<br \/>\n##<br \/>\n#############################################################################<\/p>\n<p>$Message = $Message + $tableHeader + $Tablebody + $tableend<\/p>\n<p><\/code><\/p>\n<p>This gives us pretty output we can send to users.  I hope it helps. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the things we commonly need is a list of user info. Putting that together in code is easy &#8211; but if we want a nice output to send to users? This does that. $InputSAM = &#8220;SAMACCOUNTNAME&#8221; ############################ ## ## Get user object ## ############################ $ObjUser = Get-ADUser -Identity $InputSAM -Properties * ############################ ## &hellip; <a href=\"https:\/\/www.atlanta247.com\/blog\/2018\/02\/12\/a-list-of-user-info\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">A list of user info..<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8,9,7],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scsm","category-work"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":1,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":66,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts\/65\/revisions\/66"}],"wp:attachment":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}