Get report for Last Logon Time with Active Directory

I want to get this report because, sometime we must know that pc always use local user or their domain user. So, if i can grab this information from Active Directory, i can give it to user and tell them to use their domain user. User complain to us that they cannot access folder sharing on server because they only use their local user.
I search on internet and i found this from
  1. Open Powershell ISE.
  2. Create a new script with the following code (Define "domain" and "export-csv" fields):
    $Domain = "na.local"
    $InactiveFor = 0
    $Time = (Get-Date).Adddays(-($InactiveFor))
    Get-ADUser -Filter {LastLogonTimeStamp -lt $Time -and enabled -eq $true} -Properties LastLogonTimeStamp |
    select-object Name,@{Name="Stamp";
    Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp).ToString('yyyy-MM-dd_hh:mm:ss')}} | export-csv C:\temp\lastlogon.csv –notypeinformation
  3. Run the script.
  4. Open a file produced by the script in MS Excel.


Popular posts from this blog

karimun ganti alternator 70A

FTP Batch Command