locked
Exporting Last Logon Time RRS feed

  • Question

  • I had a script that export the last logon time:

    Get-ADUser -Filter * -Property LastLogonTimestamp | Select SamAccountName,@{Name='Last Logon';Expression={$_.LastLogonTimeStamp.ToString()}} | Export-CSV C:\Export1.csv -NoTypeInformation

    i want to add the display name of the accounts, 

    do yours have any solution??

    Wednesday, December 25, 2013 1:08 PM

Answers

  • Just add any property you're looking for to the select statement

     
    Get-ADUser -Filter * -Property LastLogonTimestamp | Select Name,SamAccountName,@{Name='Last Logon';Expression={$_.LastLogonTimeStamp.ToString()}} | Export-CSV C:\Export1.csv -NoTypeInformation


    Hope that helps! Jason

    • Marked as answer by Lior Efraim Wednesday, December 25, 2013 2:43 PM
    Wednesday, December 25, 2013 1:48 PM

All replies

  • Just add any property you're looking for to the select statement

     
    Get-ADUser -Filter * -Property LastLogonTimestamp | Select Name,SamAccountName,@{Name='Last Logon';Expression={$_.LastLogonTimeStamp.ToString()}} | Export-CSV C:\Export1.csv -NoTypeInformation


    Hope that helps! Jason

    • Marked as answer by Lior Efraim Wednesday, December 25, 2013 2:43 PM
    Wednesday, December 25, 2013 1:48 PM
  • You actually need to do a few things to make this work.

    Get-ADUser -Filter * -Property * | 
          Select SamAccountName,
                 DisplayName,
                 LastLogonDate


    ¯\_(ツ)_/¯

    Wednesday, December 25, 2013 2:27 PM
  • HI JRV,

     How do i add the user PC name to this list?

    As

    Thursday, June 15, 2017 6:24 AM
  • HI JRV,

     How do i add the user PC name to this list?

    As

    What is a user PC list.  Are you asking for the array LogonWorkstations?  Just add it to the select command.


    \_(ツ)_/

    Thursday, June 15, 2017 6:28 AM
  • HI,

    No its not return the Workstation name ?

    As

    Sunday, June 18, 2017 11:18 PM
  • This is a very old post.  It has been answered.  You are asking a completely unrelated question.  Please start a new question with clear information about what you are trying to do, a script example and any error messages.


    \_(ツ)_/

    Sunday, June 18, 2017 11:26 PM