Jump to content
Sign in to follow this  
rikho

Get the last_login of a computer on an active directory

Recommended Posts

rikho

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.

Share this post


Link to post
Share on other sites
rikho

Need Guru help please >_

Share this post


Link to post
Share on other sites
water

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 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  

×