Hi,
as the title suggests we're looking for a way to track whose logged onto what machine, and a simple script solution would be ideal, basically something to modify the computer description field to reflect the username or fullname of the logged on user.
Thanks
Software/Hardware used:
ASKED:
March 25, 2008 4:56 AM
UPDATED:
October 12, 2011 4:57 AM
I think you proberbly should add the username variable to the output text entry otherwise the each time a log is created it will overwrite and not append the previous version.
something like > \\share\path\%username%.txt would do it
Putting two greater than signs (“>>” instead of just “>”) tells cmd to append to the file instead of just replacing and overwriting it.
That said, I’m not sure what sorts of file locking cmd uses; my guess is that it doesn’t have any, which could potentially be an issue if many users will be logging on (and thus running the script) simultaneously.
thanks for your response, but im specifically looking to add the user name to the description field of the computer’s name (this description appears when viewing the domain/work group).
thanks guys.
Why not just do this in Active Directory?
Create a vb script:
Set objSysInfo = CreateObject(“ADSystemInfo”)
Set objUser = GetObject(“LDAP://” & objSysInfo.UserName)
Set objComputer = GetObject(“LDAP://” & objSysInfo.ComputerName)
REM strMessage = objUser.CN & ” logged on to ” & objComputer.CN & ” ” & Now & “.”
strMessage = objComputer.CN & ” ” & Now & “.”
objUser.Description = strMessage
objUser.SetInfo
strMessage = objUser.CN & ” ” & Now & “.”
objComputer.Description = strMessage
objComputer.SetInfo
Make sure Active Directory users can edit this field:
1) Right-click the OU/container where computer accounts reside and choose “Delegate Permissions” (do NOT do it for the whole AD as this will allow editing description of any computer object including Domain Controllers)
2) Click “Next” and in the next dialog add “Domain Users” group
3) In the next dialog select “Create a custom task to delegate”
4) Select “only the following objects in the folder” and check “computer objects” in the listbox
5) Click Next. In the next dialog make sure only “Property specific” is checked under “Show these permissions”
6) Check “Write description”
7) Click Next and Finish
http://blogs.technet.com/b/heyscriptingguy/archive/2005/04/29/how-can-i-change-the-user-and-computer-account-description-attributes-each-time-a-user-logs-on.aspx
Hi all,
I would like to suggest you to use a VBscript that updates the AD Computer Description with Username and Serial Number:
sn = GetSerialNumber
UpdateDescription(sn)
Function GetSerialNumber
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!” & strComputer & “rootcimv2″)
Set colBIOS = objWMIService.ExecQuery _
(“Select * from Win32_BIOS”)
For each objBIOS in colBIOS
GetSerialNumber = objBIOS.SerialNumber
Next
End Function
Sub UpdateDescription(strDescription)
Set objSysInfo = CreateObject(“ADSystemInfo”)
Set objUser = GetObject(“LDAP://" & objSysInfo.UserName)
Set objComputer = GetObject(“LDAP://" & objSysInfo.ComputerName)
objComputer.Description = objUser.CN & ” ” & strDescription
objComputer.SetInfo
End Sub
———————————-
Again I would suggest you to use GPO’s instead of using such scripts.
You can also try third party tools like LELM, to work better in your AD.
Thank you
Anil
Lepide