VBScript to set computer description to username and login time

TriumphLTD
TriumphLTD used Ask the Experts™
on
Hi There,

I recently audited a system whereby there was a VBScript applied via a GPO that set the AD account properties of a PC's description to the username and login time of the user that last logged in.

Would anyone know how to do this?

Thanks

Dave
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Active Directory Engineer
Top Expert 2012
Commented:
I think that your answer is here

http://www.experts-exchange.com/Software/Server_Software/File_Servers/Active_Directory/Q_23787436.html?sfQueryTermInfo=1+10+30+comput+descript+set+vb

an extract:

Set objSysInfo = CreateObject("ADSystemInfo")
 
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
 
strMessage = objUser.CN & " logged in at " & objComputer.CN & " " & Now & "."
 
objComputer.Description = strMessage
objComputer.SetInfo

save it as VBS file and use in GPO at log on.

Regards,
Krzysztof

Commented:
TriumphLTD

You will also need to delegate control on the computer description field so that all users will be able to update it when the login script runs.

http://technet.microsoft.com/en-us/library/cc775585(WS.10).aspx
http://mcpmag.com/articles/2001/11/01/delegate-passing-administrative-control-with-active-directory.aspx

Author

Commented:
Hi There,

Thanks for these answers, looking at the other thread it seems I need two things:

1. A way to change the computer description locally to the logged in user and the date.
2. A way to update this change to AD.

I think the script you have given me will update to AD but does not change the computer description to that of the logged in user and the date?
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Krzysztof PytkoSenior Active Directory Engineer
Top Expert 2012

Commented:
no, it sets up under computer description
user name
computer name
and date

Author

Commented:
Ok great, i'm making progress the script is being applied via a GPO but now I get the aatched error on all PC's when they login. Any ideas?
error.bmp
Krzysztof PytkoSenior Active Directory Engineer
Top Expert 2012

Commented:
as Ken said. you need to grant all users permission to modify computer's description field.

I forgot about this becuase I did it on my admin account :/

Author

Commented:
ok course forgot about that...! I've delegate the permissions and on the SBSComputer container I have said that Domain Users has read/write access to object computers. This has worked! Is this the right way to do it though?

Commented:
I would only give users read\write to the computers description field.

Author

Commented:
I agree, but would you know how to do this as I couldn't see a setting for this?

Commented:
Right click the OU the computers are in and select Delegate
Add Domain Users
Create a custom Delegation
Select only this object and computer objects
Select read descrtion and write description

Author

Commented:
Ok great this is working brilliantly, the only thing I have noticed is that it will update the AD properties but not the local comptuer description - is this possible as well?

Author

Commented:
ok great, big thanks Ken and ISiek this is now working perfectly.

Dave

Commented:
TriumphLTD, you could split points or give assist.
Krzysztof PytkoSenior Active Directory Engineer
Top Expert 2012

Commented:
Thank you :)
but next time I would suggest to split points, especially that Ken helped you more than I :]

Author

Commented:
That's what I would like to do but there is no option this to to give assisted solution, normally it's just a button by the post isn't it?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial