Quantcast
Viewing all articles
Browse latest Browse all 21975

How can I combine this query?

$Username = Read-Host "Username"
Write-Host "Searching Domain Controllers..."
$DomainControllers = Get-ADDomainController -Filter *

     ForEach($Controller in $DomainControllers)
            {
                Get-ADUser -Identity $Username -Server $Controller.Hostname -Properties AccountLockoutTime,LastBadPasswordAttempt,BadPwdCount,LockedOut | Format-Table @{name="Domain Controller ";Expression={$Controller}},AccountLockoutTime,LastBadPasswordAttempt,BadPwdCount,LockedOut -AutoSize
            }

Hi Everyone,

Thank you for taking the time to read my post, it's greatly appreciated. I've asked a similar question like this but I think it's different enough to warrant a new question as the other answer was for something different to my eyes. When I run the above script (which is part of a larger function) it brings back all the data I'm looking for in the below format, but for each domain controller so it'll return about 12 different headers which isn't as clean as I would like it to be.

Domain Controller  AccountLockoutTime LastBadPasswordAttempt BadPwdCount LockedOut
--------------------  ----------------------- ---------------------------- ---------------  -----------

My question: Is it possible for me to have this output under the same table instead of 12 individual ones without the use of third party plugins?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>