PowerShell Active Directory: Get last logon date of a deleted user

So, my first post in this noble community. I've been lurking here and I've been getting some good information. Hopefully, you guys can help me in this concern which may be simple to some but I couldn't seem to get around it.
Is it possible to get the last logon date of a DELETED user in Active Directory?
I can get the available properties of deleted users using the following:
Get-ADObject -Filter {samaccountname -eq <account_name> -and ObjectClass -eq "user"} -IncludeDeletedObjects -Properties *
But the last logon date is not one of the properties available from Get-ADObject. Get-ADUser has the last logon property, but it does not have data on deleted users. Is there anyway this can be achieved? Perhaps convert an ADObject to an ADUser?
Any information would be much appreciated. Thank you.

Thanks everyone for your response. It looks like jrv is leading me to the right path, but I'm still having issues. I'm trying to get the lastlogon time by querying all the DCs in our domain, but every query returns a null lastlogon time for all the deleted
users I tried:
$DomainControllers = ((Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }).Name
foreach ($DC in $DomainControllers)
    $dn=(Get-ADObject -Filter {samaccountname -eq <user_account>} -includedeletedobjects -server $DC).DistinguishedName
    $user=[adsi]"LDAP://$dn"
    $user.LastLogon
It always returns null. Morever, simply executing [adsi]"LDAP://$dn" from each DC gives the following error:
format-default : The following exception occurred while retrieving member
"distinguishedName": "There is no such object on the server.
    + CategoryInfo          : NotSpecified: (:) [format-default], ExtendedType
   SystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember,Microsoft.PowerShell.Comm
   ands.FormatDefaultCommand
It's a bit surprising to me though, since $user=[adsi]"LDAP://$dn" does return a value for $user (instead of null whenever an error is encountered) of type System.DirectoryServices.DirectoryEntry but it has no members.
Anyone know what I'm missing?

Similar Messages

  • How to find the Last logon detail of a deleted user?

    I need to find the last logon detail of a deleted user.I have tried with SM20 i got the details,but i coildnt get for few users.Is there any other way to get this?

    Hi Eva,
    Follow below:-
    1. Go to Se16
    2. table name either USH02 or USH04
    3. provide BNAME row as your user name then execute it
    4. you will get all the entries for that user in the next output screen
    5. Check the Column names like
    MODDA 
    MODTI
    MODBE   
    TCODE REPID
    For the Details which you need.
    The descriptions of this columns are as below:-
    MANDT                        
    Client
    BNAME                        
    User
    MODDA                        
    Modification date
    MODTI                        
    Modification time
    MODBE                        
    Changed by
    TCODE                        
    Not More Closely Defined Area, Pos
    REPID                        
    Program Name
    BCODE                        
    Initial password
    GLTGV                        
    Valid from
    GLTGB                        
    Valid through
    USTYP                        
    User Type
    CLASS                        
    User group
    UFLAG                        
    User Lock Status
    ACCNT                        
    Account number
    PASSCODE                     
    Password Hash Val.(SAH1, 160 Bit)
    CODVN                        
    Password Code Vers.
    PWDINITIAL                   
    Indicator: Password Is Initial
    Let me know if you need further help in this.
    Regards,
    Ram

  • Last login date of a deleted user

    Hi there,
    Could you please let me know how to find the last login date of a deleted user in the SAP.
    Thanks
    Amit.

    Hi Bernhard,
    Thanks a ton for the reply.
    you are correct that they you cannot get the details of a deleted user from USR02 but they are ways in which you can still find the last login date of a deleted user.
    One of the ways is using of transaction SUIM but i have no idea why this is not working in my system.
    Anyways if you can find any relevant detail please let me know.
    Regards
    Amit

  • Last Logon Date for Deleted Users

    Hi,
    How can I checked to see last logon date for a deleted user-SAP ECC 6.0?
    -Wes

    > ... chekcing USR02 the TRDAT field has been reset.
    In lower releases you could easily have made a big mistake doing that.
    In all releases the security audit log (SM20) is the correct tool for this, but you cannot retro-fit it.
    If the SM20 log is not activated for logon events, then there are several other ways of reconstructing parts of the information but they are all incomplete and a big effort.
    Cheers,
    Julius

  • Last logon date

    Hi,
    I am working on EP 7.0 SPS 13.
    We have LDAP & UME as data source.
    Is there any way to get last logon date for all users?
    UME method for getting last logon details is deprecated.
    What is alternative way?
    I need to get list of all users who have not logged on to portal for last 30 days.
    Is there any way to achieve this?
    Regards,
    Apurva

    Hi Michael,
    Thanks for the link.
    Our requirement is that if user is not active for say 30 days his userid should be locked and after say 60 days it should be deleted.
    In order to determine inactive users we need information about logon details for user ids. Portal Activity Report - Details of users who logged on does not consider reporting period and hence is of no use.
    Is there any operation in this web service which can provide us this information?
    Regards,
    Apurva

  • Get last logon + user name

    Hi Everyone 
    first on all where is the powershell forum ?
    I need help with powershell,
    we have file ( Excel -CSV )  that contains names of 70  computers name ,
    I want to know which user did logon and  who is now is login.
    NOTE :
    I succeed to get the last login but I do not know which user did logon
    I will happy if someone help me , thank you and i appreciate you
    My Website:www.Pelegit.co.il Mcitp /Mcsa 2012

    Hi Meir,
    >>Get last logon + user name
    Regarding this question, the following thread can be referred to for more information.
    How to display last login user account in active directory ?
    https://social.technet.microsoft.com/Forums/en-US/8609ce4d-b15f-447b-bc37-142021b9e00c/how-to-display-last-login-user-account-in-active-directory-?forum=winserverDS
    >>first on all where is the powershell forum ?
    Windows PowerShell
    https://social.technet.microsoft.com/Forums/Windows/en-US/home?forum=winserverpowershell
    Best regards,
    Frank Shen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Script to pull out last logon date

    Hello,
    I have a list of user that I would like to pull out last logon date from AD.
    This is the script I am using at the moment but it produces blanks and I don't know what the blanks mean.
    Import-Module ActiveDirectory
    #This script requires PowerShell AD Module
    Import-csv "c:\scripts\samaccountname.csv" |
    foreach-object {get-aduser $_.samaccountname -Properties lastlogondate} |
    select name,Lastlogondate |
    Export-csv c:\scripts\LastLogon.csv -NoTypeInformation
    Please can you help?
    Kind Regards, PenDraKon

    If you want an accurate lastLogon date, you have to check across domain controllers.
    Here's an advanced function I created a while ago for this.
    Function Get-LastLogon {
    <#
    .SYNOPSIS
    Returns LastLogon information
    .DESCRIPTION
    Queries the LastLogin information for a user across domain controllers and returns the highest (latest) value
    .EXAMPLE
    Get-LastLogon User
    .EXAMPLE
    Get-LastLogon -Identity User
    .EXAMPLE
    Get-ADUser User | Get-LastLogon
    .EXAMPLE
    Get-LastLogon User1, User2
    .PARAMETER users
    List of users - pipeline can be used
    #>
    [CmdletBinding()]
    param
    [Parameter(Position= 0,
    Mandatory=$True,
    ValueFromPipeline=$True,
    HelpMessage='What user would you like to find the last logon for?')]
    $identity
    Begin {}
    Process {
    Foreach ($account in $identity) {
    $dateStamp = $null
    $domainController =$null
    Get-ADDomainController -Filter * | Foreach {
    $dc = $_.HostName
    $lastLogon = (Get-ADUser $account -Properties LastLogon -server $dc | Select-Object Name,@{n='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon)}}).Lastlogon
    If ($dateStamp -le $lastlogon)
    $dateStamp = $lastlogon
    $domainController = $dc
    } # End of ForEach
    $properties = @{
    Name=$account;
    LastLogon=$dateStamp;
    DomainController=$domainController}
    New-Object -TypeName PSObject -Prop $properties
    } # End of ForEach
    } # End of Process
    End {}
    } # End of Function
    You can then run...
    Import-CSV ".\samaccountname.csv" | % {Get-LastLogon $_.samaccountname}
    or...
    Import-CSV ".\samaccountname.csv" | % {Get-LastLogon $_.samaccountname} | Export-CSV ".\report.csv" -noType

  • Search for User by last logon date no longer works after upgrading to SPS18

    We used to be able to Search by last logon date under User Administration as a quick way to find out who logged on for a particular date.  It worked well, but only for a single date range.  We were on EP 6.0 SPS13 at the time.  Since we have upgraded to SPS18, it no longer works.  All we get back now is no user found no matter what date we enter. 
    Has anyone else experienced this problem?  I've been searching and haven't found anything.  I wanted to try and get more information before I create an OSS message.
    Thank you,
    Kathy

    it's since SP16, to be correct: http://help.sap.com/saphelp_nw04/helpdata/en/43/bc6b9202454dece10000000a422035/frameset.htm
    kr, achim

  • Need FM to get Last change date of Objects in package

    Hi All,
      Is there any Function module to get Last changed date of all Objects in a package .
      How to get the last change date of class,methods,function module.....
      I can get last change date of programs from TRDIR....UDAT....Similarly how can I get for Function Module and Class Methods. 
    With Thanks,
    Dina.
    Message was edited by: Dinamol Sasidharan

    Go/double click on the affected cubes you want to see the time stamp.
    click the Extras(tab on the upper of part of SAP) or simply 'Ctrl + F5'.
    Box will appear.
    Click on Logs for Save/Activate so you will see the linfo for the users who used this cube.
    Then put time restriction for From and To(always the current day and time).
    Then execute, all of the users who changed then saved/activated that cube will appear on that timeframe you view.
    Hope this help.

  • Hi all, can someone help me in getting last login date of a user in CQ5 please?

    Hi all, can someone help me in getting last login date of a user in CQ5 please?

    CQ is REST based and does not have the concept of session. So there is no feature to track login or logout details.  Most of our customers use some kind of central authentication Ex- SSO hence no need arises to have such functionality built in.  However if needed you have the ability to implement such at a project level solution. Ex:- custom login modules or auth-handler by taking project specific constraints and requirements into account

  • How to get last modified date and time of a file which is in apache server.

    Hi ,
    I need to get last modified date and time of a file in remote machine.
    This file is in remote machine which has apache server installed.
    I am trying to get this information by connecting to apache server from client by giving absolute URI of the file to file object.
    URI is got from apache server URL by using toURI method.
    when I use lastModified method , its throwing exception , because scheme of URI is not file.
    I can't give scheme as file because ftp server is not installed on that server
    Is there any other way to get this information .

    No, unless you can use an FTP client.

  • How to get last Build date of a dll in the real time target

    Info On My Project    
       I am working on LabWindows CVI 12.0 for development . This project is a real time application for hardware, which is having Phar Lap ETS as RTOS...  
    I am facing some problems while checking Build date of my Application file( .dll)
    I have tried to use GetFileDate API. But it is not supporting for realtime Target..
    So i have tried __DATE__ macro.. That also having some problems..
    How to get last Build date of a dll from the real time target  ??
    Please Help to solve this....
    Thanks
    Vaishakh A  K

    Please reply if any one have suggestion...

  • Last Logon date and Logon time not updating in table USR02

    Hi,
    Please help us on this. After customer successfully logged in the webshop, we are checking the table USR02 in CRM system and the Logon date and Logon time is not updated. Because of this, the customer will be locked after certain number of days. When we check it in ECC system, customer's last logon date and time is updated. Can you tell us what could be causing this? Any advise what we need to check? Thanks in advance!
    Regards,
    Mike

    Hi
    1. Please check if the USAPPLREF table in ECC has the correct mapping done between the LOGON User and the Sold-to party (Customer)
    2. Please check the validity of those user in SU01 user data.
    3. Please check the USERS data from the USERADMIN Link (if it is configured in your scenario through XCM settings for USERS)
    Hope this will help.
    Regards

  • Is there a system table or V$ view that will show a user's last logon date?

    Is there a system table or V$ view that will show a user's last logon date?
    I'm using Oracle 9.2.0.7

    sqlplus
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 31 12:44:42 2010
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Enter user-name: / as sysdba
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> desc user$
    Name                            Null?    Type
    USER#                            NOT NULL NUMBER
    NAME                            NOT NULL VARCHAR2(30)
    TYPE#                            NOT NULL NUMBER
    PASSWORD                             VARCHAR2(30)
    DATATS#                       NOT NULL NUMBER
    TEMPTS#                       NOT NULL NUMBER
    CTIME                            NOT NULL DATE
    PTIME                                  DATE
    EXPTIME                             DATE
    LTIME                                  DATE
    RESOURCE$                       NOT NULL NUMBER
    AUDIT$                              VARCHAR2(38)
    DEFROLE                       NOT NULL NUMBER
    DEFGRP#                             NUMBER
    DEFGRP_SEQ#                             NUMBER
    ASTATUS                       NOT NULL NUMBER
    LCOUNT                        NOT NULL NUMBER
    DEFSCHCLASS                             VARCHAR2(30)
    EXT_USERNAME                             VARCHAR2(4000)
    SPARE1                              NUMBER
    SPARE2                              NUMBER
    SPARE3                              NUMBER
    SPARE4                              VARCHAR2(1000)
    SPARE5                              VARCHAR2(1000)
    SPARE6                              DATE

  • BAPI_USER_GET_DETAIL - Last Logon Date not available

    From R3 I want to check the last logon Date (USR02-TRDAT) of a user in an outside system such as EBP or BW.  BAPI_USER_GET_DETAIL seemed like a good choice but TRDAT is not passed to the BAPI. Last Logon Time is (LTIME) but not Last logon date (TRDAT). How can this be easily done.
    Thanks,
    -don.

    the problem with this is that it makes a call for each user. If you have 100k users it becomes a very inefficient process.
    If you build something in the backend to collect the details a useble format....1) it is custom, and 2) you need to deply in each backend and 3) maintain it in each backend.
    not a good solution.
    If anyone has better idea please shout. Again....this RFC call does the job.....but it is like empting a pool full of water with a  teaspoon, does the job but very inefficiently.
    DenisO

Maybe you are looking for

  • Syncing Numerous Devices with iTunes Library on a Mac Mini

    My MacBook Pro ran out of space, so I bought a Mac Mini with a 750 GB Hard Drive to store all of my music and photos (the Mac Mini is acting as a Media Center).  Anyway, I wish to use this library to sync with my iPad and iPhone--BUT THROUGH MY MAC B

  • Report Painter, GL Set does not have description

    Hi Expert, I want to create Columnar Financial Statement (Profit and Loss Account, and Balance Sheet). My problem is that my GL under the lead column does not have any GL description shown. I tried some of the settings for lead column under formattin

  • How to set current time ?

    Hi, I am in eastern time zone and my Apex sysdate shows EST. However the date picker shows four hours ahead (GMT) . The reason I found is the current_time stamp set to 00:00 instead of -04:00. (DBTIMEZONE) . Our DBA does not know much about APEX . Wh

  • Query regarding UPGRADE SAP NW BI 7.0 to BW 7.3

    Hi, What are the prerequests needed to upgrade from NW7.0(EHP1) BI system to new SAP BW 7.3 ? is it possible? if YES, what are things need to taken care. if NO what are the prerequest need to be done in existing NW 7.0 (EHP1) BI system? Your response

  • Synching issue with Safari

    Why doesnt the iphone sync my safari bookmarks when I update them?