Link to home
Start Free TrialLog in
Avatar of outrun17
outrun17

asked on

active directory computers field not slowing users

I have windows 2003 server and in active directory the computer tab slows me all my computers but not the username that is using that computer.

how can i made the username slow?

SOLUTION
Avatar of smilerz
smilerz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can also use PsLoggedOn to retrieve the current user.
http://www.microsoft.com/technet/sysinternals/Security/PsLoggedOn.mspx

If nobody is currently logged on, you can use the script from this article to find out who logged on last:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan07/hey0123.mspx
Avatar of outrun17
outrun17

ASKER

How about is i want to see all the computers list that i have in AD show the computer name and on the right of it want user?
This script will do what you want:

_______
Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from 'LDAP://DC=fabrikam,DC=com' " _
        & "Where objectClass='computer'"  
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    strcomputer =  objRecordSet.Fields("Name").Value
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
      & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
      Wscript.Echo strcomputer & vbTab & objComputer.UserName
Next
    objRecordSet.MoveNext
Loop
do I add this script in AD? also with the"."

i need  to have it all computers in ad how would i do it/
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
smilerz

would i add that in ad?
Name the script LoggedInUsers.vbs and execute it from the command line:
cscript.exe LoggedInUsers.vbs
it will display the computers and logged in users in the command shell.
smilerz

I would like it to show in AD so i don't have to go to each computer and run it. i want so when i log on to the server and click on computers then i see the list of computers with the user name thats using that computer.

There isn't any way to do that - the best you can do is run a script to show currently logged in users.
SMS provides a similar view if you use SMS - but ADUC doesn't support this functionality.  The currently logged in user is not stored in the directory.
See the last script I linked to.  It will put the name of the last user to sign on in the computer's Description field.  This will then show up in AD Users and Computers.
Shift-3

give me that script again.

Shift-3

and where would i add this script?
Shift-3

I just added the script that you gave to me the server; but now sure why its not working. please tell me steps when i need to do when i have the script on my computer.

I now have it on my desktop.

Shift-3
 please tell me step by step on what i need to do and give me the hole script.

Thank you so much for all you help that your giving.

You need to run that script as every users login script so that they update their computer description when they log on.
I understand that; but would I add it in AD as a group polcy? where would i do that?
how would i run the script? when will i do it on each computer or do i add the script in AD and if so how will I do it?

thanks
You can create a group policy object - there is a logon script parameter that can be set.
I think I got it to work with this script. I created a test.vbs but I need to know how will i run it on all the computer in my AD. where do I place the script and where. here is the script.

Set objSysInfo = CreateObject("ADSystemInfo")

Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)

strMessage = objUser.CN & " logged on to " & objComputer.CN & " " & Now & "."

objUser.Description = strMessage
objUser.SetInfo

objComputer.Description = strMessage
objComputer.SetInfo
can you give me step by step, because i can not find it.
I added the script in AD in the group policy object - there is a logon script parameter.

Then I login in a workstation after that I looked in the server AD but it did not give me the username by the computer field.

any ideas?