How do I fix this so it doesn’t create headings on each account?
UserName LockoutTime DCName accountexpires PasswordNeverExpires
testguy 0 DC3 0
UserName LockoutTime DCName accountexpires PasswordNeverExpires
testguy 0 DC1 0
$DCs = Get-ADDomainController -filter * | select -ExpandProperty Name foreach($d in $DCs) { $results= Get-ADUser -Identity testguy -Properties samaccountname,LockoutTime,badpasswordtime,pwdlastset,accountexpires -server $d $Properties = @{UserName = $results.samaccountname LockoutTime = $results.LockoutTime badpasswordtime = $results.badpasswordtime DCName = $d accountexpires = $results.accountexpires PasswordNeverExpires = $results.passwordNeverExpires } $Obj = New-Object -TypeName PSObject -Property $Properties | Select Username,LockoutTime,DCName,accountexpires,passwordneverexpires $obj | format-table }