cmdown
asked on
vbscript - get user and computer details from AD
Does anyone have a vbscript that will query both the local computer and AD (as appropriate) to return the information below. I'm struggling about with forming the required LDAP calls.
current (logged on) UserName
Computer (Host) Name
IP Address
OS version & service packs (if applied)
Location of computer (from AD)
I'd also like to amend the script so as to query the whole domain and return most of the above information in a csv file but with last logged in user & date/time instead of current Username.
Domain Name = MyDomain.Local
Domain Controller = MyDC
Script needs to run on both XP Pro and Windows 7 Pro
The domain is Server 2003
current (logged on) UserName
Computer (Host) Name
IP Address
OS version & service packs (if applied)
Location of computer (from AD)
I'd also like to amend the script so as to query the whole domain and return most of the above information in a csv file but with last logged in user & date/time instead of current Username.
Domain Name = MyDomain.Local
Domain Controller = MyDC
Script needs to run on both XP Pro and Windows 7 Pro
The domain is Server 2003
The plan is:
Search through AD for the “computer” object types and retrieve the Computer Name, OS version, service Pack and Location.
Go through each of these computers to check for the “Logon User Name” registry entry to query AD (again) for the users “Last logon Time” property.
And save it in a csv format.
Just give me some time, and I’ll get you the script.
Search through AD for the “computer” object types and retrieve the Computer Name, OS version, service Pack and Location.
Go through each of these computers to check for the “Logon User Name” registry entry to query AD (again) for the users “Last logon Time” property.
And save it in a csv format.
Just give me some time, and I’ll get you the script.
can you give example to exectly what you want
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
must change line 1 with your correct LDAP Path
Const LDAPPath = "LDAP://DC=MyDomain,DC=Loc al"
Const LDAPPath = "LDAP://DC=MyDomain,DC=Loc
..I'll try and get you the 2nd version today
ASKER
Thanks x-men
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks x-men
On running ee2, it generates an error on line 17, with strComputer containing the name of a long defunct server - removed from the domain circa 3 years ago. Where is it getting this name from?
On running ee2, it generates an error on line 17, with strComputer containing the name of a long defunct server - removed from the domain circa 3 years ago. Where is it getting this name from?
ASKER
ee1 runs but returns an odd result as below:
OS version & service packs: Microsoft Windows XP Professional - 5.1.2600 - Service Pack 3
PDSK-Site1-Office1 does not exist in:
LDAP://DC=MyDomain,DC=loca l
The pc is a member of the domain.
OS version & service packs: Microsoft Windows XP Professional - 5.1.2600 - Service Pack 3
PDSK-Site1-Office1 does not exist in:
LDAP://DC=MyDomain,DC=loca
The pc is a member of the domain.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the delay in replying x-men. I'll have a look at the above - but I'm on leave until 7th June so it may not be until then.
how did it work out?
ASKER
Hi x-men
Sorry for the delay. I've been off ill for a while. Thanks for all your help with this one.
Sorry for the delay. I've been off ill for a while. Thanks for all your help with this one.
http://www.joeware.net/freetools/tools/adfind/index.htm
adfind -default -f "objectcategory=computer" name operatingsystem operatingsystemservicepack
Guys from the VBScript zone may help with the other info but things like last logged on user have to be pulled from event logs.
Thanks
Mike