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...
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
#157341 - 2006-02-1608:12 PMRe: Tell when a machine was added to domain
NTDOCNTDOC 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.
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?
#157344 - 2006-02-1611:29 PMRe: Tell when a machine was added to domain
NTDOCNTDOC 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
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.