Question : Change Computer Desc based on AD email field VBS

Hi All

I am trying to setup a script which will change the local computer desc everytime a user logs on i found the below script, but i see the it updates that in the AD, any ideas how to have it change on the local pc?, also i would like it write the full email on the description ex- [email protected]
it should read it from the email field on the AD
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
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
Open in New Window Select All

Answer : Change Computer Desc based on AD email field VBS

Well i figured it out heres the code if anyone needs it, it will input email address on the Description Tab

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Set objNetwork = CreateObject("Wscript.Network")
Set objADSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objADSysInfo.UserName)
SetComputerDescription objUser.Mail
 
Function SetComputerDescription(computerDescription)
    Dim objSWbemServices,colSWbemObjectSet,objSWbemObject
    Set objSWbemServices = GetObject("winmgmts:\\.\root\cimv2")
    Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_OperatingSystem")
 
  For Each objSWbemObject In colSWbemObjectSet
      objSWbemObject.Description = computerDescription
      On Error Resume Next
      objSWbemObject.Put_
  Next
End Function
Open in New Window Select All
Random Solutions  
 
programming4us programming4us