HI all
I am having some issues writing a script that get me accurate results. I'm using Quest cmdlets to query and return last logon results for users in a specific OU.
Whilst my script runs without issue and returns results it doesn't seem to be accurate with the time stamps. It returns blanks which would imply the user hasn't logged on but I know for a fact that they have. Therefore the information can not be trusted.
So in short how do I get a script to query all domain controllers in my domain and return accurate log on times for all users in specific OU's
Below is the script for reference. I cant take credit for this as it was cobbled together from a number of scripts I found on line.
Get-PSSnapin -Registered
Add-PSSnapin Quest.ActiveRoles.ADManagement
Set-QADPSSnapinSettings -DefaultSizeLimit 0
$Userlist = Get-QADUser -SearchRoot “OU=a,OU=b,DC=ab123,DC=abc”
$Report = @()
Foreach($User in $Userlist){
$Userdata = Get-QADUser -Identity $User |
Select FirstName, LastName, DisplayName, SAMAccountName, LastLogon, Office
$Report += $Userdata
}
$Report | Export-Csv -Path c:\logontimes.csv -NoTypeInformation
Thanks in advance.
Chris