Jump to content
Sign in to follow this  
rikho

FQDN from computername (only)

Recommended Posts

rikho

Hi all,

I got the solution for a user, but for a computer there is always the same problem.

$LastLogonTimeStamp = _ADGetObjectAttribute($username, $attribute)

chen i change $username by $computername --> error : Variable must be of type object !

Can u drive me on the solution way

Need to get attribute about computer in my AD.

please need a master...

thx

Share this post


Link to post
Share on other sites
water

To get info for a computer you have to append "{:content:}quot; to the computername to get a valid sAMAccountname:

_ADGetObjectAttribute(@ComputerName & "{:content:}quot;,"lastLogon")

Unfortunately you have to translate the returned data into a readable form. The lastLogon data (at least for users) is not propagated to all Domain Servers immediately. To get the "real" last logon date you have to ask all Domain Servers and take the most current.

I have posted some code to get the "true" logon date and to convert the returned data into readable form. I'm on vacation so please have a look at the forum yourself or - if it is not that urgent - wait till I return.

Or have a look at this post.

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
rikho

To get info for a computer you have to append "{:content:}quot; to the computername to get a valid sAMAccountname:

_ADGetObjectAttribute(@ComputerName & "{:content:}quot;,"lastLogon")

Unfortunately you have to translate the returned data into a readable form. The lastLogon data (at least for users) is not propagated to all Domain Servers immediately. To get the "real" last logon date you have to ask all Domain Servers and take the most current.

I have posted some code to get the "true" logon date and to convert the returned data into readable form. I'm on vacation so please have a look at the forum yourself or - if it is not that urgent - wait till I return.

Or have a look at this post.

Thank you ! very much.

I hope your vacation are great and i am going to have a look at your post.

It will not be difficult to compare each date about all DC i did it in another life for users.

The main difficulty for me is to call

_ADGetObjectAttribute(@ComputerName & "{:content:}quot;,"lastLogon")

Login_computer.au3 (12) : ==> Unterminated string.:

$LastLogonTimeStamp = _ADGetObjectAttribute(@ComputerName & "{:content:}quot;"lastLogon")

i think the syntax have a problem but i cant fix it >_<

Do i have to change some value ? (i got the same error com message)

is "{:content:} = FQDN ? or the path in AD ?

I run it from a DC and will check all domain computers (then i want to delete all computer with a 6 months old lastlogon)

Regards.

Edited by rikho

Share this post


Link to post
Share on other sites
rikho

What do you mean about "{:content:}quot;

i got a syntax error while using it >_<

Share this post


Link to post
Share on other sites
water

Seems to be a problem with the forum software. It should read:

_ADGetObjectAttribute(@ComputerName & "$","lastLogon")

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  

×