Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

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?

0
outrun17
Asked:
outrun17
  • 13
  • 6
  • 3
2 Solutions
 
smilerzCommented:
This information is not available in Active Directory Users and Computers.
Below is a script that will report the logged on users for a specific computer - just change the "." to the computername that you want to check.

_____
Option Explicit
Dim objWMIService
dim objComputer
dim colComputer
dim strComputer

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
      & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
Wscript.Echo objComputer.UserName & " is logged on"
Next
0
 
Shift-3Commented:
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
0
 
outrun17Author Commented:
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?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
smilerzCommented:
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
0
 
outrun17Author Commented:
do I add this script in AD? also with the"."

i need  to have it all computers in ad how would i do it/
0
 
Shift-3Commented:
You could use the logon script from this article to dynamically update each computer's Description field with the name of the last user to sign on:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/apr05/hey0429.mspx
0
 
outrun17Author Commented:
smilerz

would i add that in ad?
0
 
smilerzCommented:
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.
0
 
outrun17Author Commented:
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.

0
 
smilerzCommented:
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.
0
 
Shift-3Commented:
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.
0
 
outrun17Author Commented:
Shift-3

give me that script again.

0
 
outrun17Author Commented:
Shift-3

and where would i add this script?
0
 
outrun17Author Commented:
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.

0
 
outrun17Author Commented:
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.

0
 
smilerzCommented:
You need to run that script as every users login script so that they update their computer description when they log on.
0
 
outrun17Author Commented:
I understand that; but would I add it in AD as a group polcy? where would i do that?
0
 
outrun17Author Commented:
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
0
 
smilerzCommented:
You can create a group policy object - there is a logon script parameter that can be set.
0
 
outrun17Author Commented:
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
0
 
outrun17Author Commented:
can you give me step by step, because i can not find it.
0
 
outrun17Author Commented:
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?
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 13
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now