Page 1 of 1 1
Topic Options
#157339 - 2006-02-16 08:00 PM Tell when a machine was added to domain
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Does anybody know of a way that I can determine programatically when a machine was added to the domain? Or even at the very least, when the machine was ghosted.

I was thinking maybe I could grab the date of some file or folder??? Not sure what would be consistent though...

Thoughts?

Top
#157340 - 2006-02-16 08:05 PM Re: Tell when a machine was added to domain
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\installdate

I don't know if that is pre- or post- image

edit, I've checked 3 imaged PCs and they are all different.

Windows NT stores its install time in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate in seconds from January 1, 1970


Edited by Radimus (2006-02-16 08:10 PM)
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#157341 - 2006-02-16 08:12 PM Re: Tell when a machine was added to domain
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Active Directory has a value you can query (don't know it off the top of my head) but the Key is when the OS was built, which is of little value in these days of Ghosting/Imaging systems.

Hmmmm... Not positive, but that key I'm thinking of might be new to AD 2003 and may or may not exist in 2000 AD.

Top
#157342 - 2006-02-16 10:26 PM Re: Tell when a machine was added to domain
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Interesting... This does appear to be different between ghosted machines.

How would I go about converting that number to an actual date? I mean I know I can multiply by 86,400 to get days and whatnot, but is there already a function that takes leap years and whatnot into account?

Top
#157343 - 2006-02-16 10:33 PM Re: Tell when a machine was added to domain
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I believe the number to be CTime. There is the FlipCTime() UDF.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#157344 - 2006-02-16 11:29 PM Re: Tell when a machine was added to domain
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Here is code to do it, but I think you'll find that if this is the SAME GHOST IMAGE that the dates will be the same. I think maybe you're looking at different images.

Jens has a UDF that does this and more called OSID


 
Break On
Dim $InstallDate
$InstallDate = cTime(ReadValue('HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','InstallDate'))
'OS Install Date: ' + $InstallDate ?


Function cTime($iSeconds,optional $iOffset)
Dim $iEpoch, $iDays, $iZ, $iH, $iA, $iB, $iC
Dim $iYear, $iMonth, $iDay, $iHour, $iMinutes

$iEpoch=719163

; Adjust time for local
$iSeconds=Val($iSeconds)+(Val($iOffset*3600))
$iDays=$iSeconds/86400
$iSeconds=$iSeconds-($iDays*86400)

$iDays=$iDays+$iEpoch

$iZ=$iDays + 306
$iH=100*$iZ-25
$iA=$iH/3652425
$iB=$iA-$iA/4
$iYear=(100*$iB+$iH)/36525
$iC=$iB+$iZ-365*$iYear-$iYear/4
$iMonth=(5*$iC+456)/153
$iDay=$iC-(153*$iMonth-457)/5

if $iMonth > 12
$iYear=$iYear + 1
$iMonth = $iMonth - 12
endif

$iHour=$iSeconds / 3600
$iMinutes=($iSeconds-$iHour*3600)/60
$iSeconds=$iSeconds-$iHour*3600-$iMinutes*60
$cTime=''+$iYear+'/'+right('00'+$iMonth,2)+'/'+right('00'+$iDay,2)
$cTime=$cTime+' '+right('00'+$iHour,2)+':'+right('00'+$iMinutes,2)+':'+right('00'+$iSeconds,2)
EndFunction

Top
#157345 - 2006-02-16 11:30 PM Re: Tell when a machine was added to domain
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
This is also when the system was built/imaged, not when it joined the Domain.
Top
#157346 - 2006-02-17 12:44 AM Re: Tell when a machine was added to domain
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Thanks again Doc... I grabbed the CTime function and it works great. For what it's worth, the InstallDate is actually showing the date the machine was ghosted, not the date the image was created.

So in other words, 2 machines with the same image. One was ghosted on 1/10/2006, and the other was ghosted on 2/15/2006....those dates are reflected in the InstallDate.

I'm thinking that maybe because I am using SYSPREP, that the sysprep process is creating a SID and finalizing the setup, which then writes those registry entries. A plain, static ghost image (non-sysprep) might have a burned-in date like you're suggesting.

And incidentally, although my original request was "date added to domain", this InstallDate value will work just as well. I just need to know when the machine was put into service. Around here they are ghosted and added to the domain within minutes. I just figured I was likely to get an AD queryable value for date added to domain so that's why I asked.

Thanks again for all the help. Works like a charm.


Edited by sixdoubleo (2006-02-17 12:47 AM)

Top
#157347 - 2006-02-17 02:00 AM Re: Tell when a machine was added to domain
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Of course that probably assumes that the technician installing the image bothered to verify that the date was correct in BIOS.

If you want the date that the system was joined to the domain look for the whenCreated property for the computer object in ADSI.

Top
#157348 - 2006-02-17 02:14 AM Re: Tell when a machine was added to domain
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Which is what I originally said, but not sure if 2000 has it or only if 2003 does.
Top
#157349 - 2006-02-17 02:31 PM Re: Tell when a machine was added to domain
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Not exactly what you said as you didn't provide the property name.

Anyway, whenCreated is available with AD 2000 as well.

Top
#157350 - 2006-02-17 09:48 PM Re: Tell when a machine was added to domain
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Quote:

Active Directory has a value you can query (don't know it off the top of my head)




sure it was, just didn't know the property name as you say. You also don't say if it applies to 2000 or 2003 or both.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.11 seconds in which 0.076 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org