Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Detect newly created computeraccounts in AD

Reply
 
Old 09-18-2008   #1 (permalink)
johan.m.eriksson


 
 

Detect newly created computeraccounts in AD

I am looking around for a vbs that could help me find computer
accounts created within for example, a week.

Our users has managed to get their hands on our deploy-floppy, and are
sometimes reinstalling their pc's without
our knowledge.

If I could do a search in our workstation OU, and get a list of
computeraccounts created within a week, I could
easily sort out which ones we installed at the IT dept. and which we
did not.

A problem is that a reinstallation in our environment reuses the old
computername automatically, and maybe those pc's will not have their
"creationattribute" changed.

But other fresh new installations will render a new computer account.

Pls help!

My System SpecsSystem Spec
Old 09-18-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Detect newly created computeraccounts in AD


<johan.m.eriksson@xxxxxx> wrote in message
news:a01aa94a-cbba-4150-8ac2-347737bad8ca@xxxxxx
Quote:

>I am looking around for a vbs that could help me find computer
> accounts created within for example, a week.
>
> Our users has managed to get their hands on our deploy-floppy, and are
> sometimes reinstalling their pc's without
> our knowledge.
>
> If I could do a search in our workstation OU, and get a list of
> computeraccounts created within a week, I could
> easily sort out which ones we installed at the IT dept. and which we
> did not.
>
> A problem is that a reinstallation in our environment reuses the old
> computername automatically, and maybe those pc's will not have their
> "creationattribute" changed.
>
> But other fresh new installations will render a new computer account.
>
> Pls help!
You can use ADO in a VBScript program to retrieve all computer objects where
the whenCreated attribute is after a specified date. For example:
===========
Option Explicit

Dim adoCommand, adoConnection, strBase, strFilter, strAttributes
Dim strQuery, adoRecordset, strDN

' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection

' Search specified OU.
strBase = "<LDAP://ou=West,dc=MyDomain,dc=com>"

' Filter on computer objects created after sepcified date.
' This example is September 1, 2008 (UTC).
strFilter = "(&(objectCategory=computer)(whenCreated>=20080901000000.0Z))"

' Comma delimited list of attribute values to retrieve.
strAttributes = "distinguishedName"

' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False

' Run the query.
Set adoRecordset = adoCommand.Execute

' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
' Retrieve values and display.
strDN = adoRecordset.Fields("distinguishedName").Value
Wscript.Echo strDN
' Move to the next record in the recordset.
adoRecordset.MoveNext
Loop

' Clean up.
adoRecordset.Close
adoConnection.Close

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to get the content of a newly created instance of IE VB Script
Unable to login with newly created accounts Vista account administration
Newly created files protected from further access Vista General
Problem logging in with newly created user Vista account administration
not able to format newly created shrink volume Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46