Jump to content

Get the last_login of a computer on an active directory


rikho
 Share

Recommended Posts

Hello everyone,

This is my code, anyway when i am checking the whenchanged date or whencreated seem's to be correct.

Func go()
$strHostServer = 'myserver_name'

    _ADGetObjectsInOU ($asComputers, $sOU, "(objectClass=computer)", 2, "name,createTimeStamp,modifyTimeStamp")

    $tt = 15
    GUICtrlSetData($Pr3, $tt)
    GUICtrlSetData($Label4, $asComputers[0][0])
    $x = 0
    
    FileOpen($report, 2)

    For $i = 0 To $asComputers[0][0]

        GUICtrlSetData($Label2, $i)
        $whenCreated = $asComputers[$x][1]
        $whenChanged = $asComputers[$x][2]

        
        MsgBox(4096, '$lastlogon_poste', $lastlogon_poste, 1000)
        

        $yyyy = StringMid($whenCreated, 1, 4)
        $mm = StringMid($whenCreated, 5, 2)
        $dd = StringMid($whenCreated, 7, 2)
        $sNewDate1 = $dd & '/' & $mm & '/' & $yyyy

        $yyyy2 = StringMid($whenChanged, 1, 4)
        $mm2 = StringMid($whenChanged, 5, 2)
        $dd2 = StringMid($whenChanged, 7, 2)
        $sNewDate2 = $dd2 & '/' & $mm2 & '/' & $yyyy2
        $x = $x + 1

        
        $lastlogon_computer = $dd3 & '/' & $mm3 & '/' & $yyyy3

        FileWriteLine($report, $asComputers[$x][0] & ';' & $sNewDate1 & ';' & $sNewDate2 & @CRLF)

        $tt = $tt + 1
        $P3 = ($tt * 100) / ($asComputers[0][0])
        GUICtrlSetData($Pr3, $P3)
        
    Next
    FileClose($report)

EndFunc

is someone got a better code to get lastlogin domain computer (and not user)

Regards.

Link to comment
Share on other sites

  • 3 months later...

I'm a bit late. To get the last login date you could use the function _AD_GetLastLoginDate from the rewritten Active Directory UDF.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...