eltel-it-nor
asked on
Problems with logon in windows 2008 when trying to run a VBS script
Greetings!
This script worked without problems in a 2003 R2 Domain, But when trying to run it in a 2008 domain nothing seems to happen.
On a client when gpresult /R is run Model.vbs is an applied Group Policy Object
Model.vbs :
'------------------------- ---------- ---------- ---------- ---------- ------
' Created 3/29/2011
' When used as login script it will populate the Computer Description
' in Active Directory with UserName, Serial Number & Computer Model
' -------------------------- ---------- ---------- ---------- ---------- ----
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set colcomputersystem = objWMIService.ExecQuery _
("Select * from Win32_computersystem")
Set colBIOS = objWMIService.ExecQuery _
("Select * from Win32_BIOS")
For each objcomputersystem in colcomputersystem
Getcomputersystem = objcomputersystem.Model
Next
For each objBIOS in colBIOS
GetSerialNumber = objBIOS.SerialNumber
Next
Set objSysInfo = CreateObject("ADSystemInfo ")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
strMessage = objUser.CN & " / " & GetSerialNumber & " / " & Getcomputersystem
objComputer.Description = strMessage
objComputer.SetInfo
This script worked without problems in a 2003 R2 Domain, But when trying to run it in a 2008 domain nothing seems to happen.
On a client when gpresult /R is run Model.vbs is an applied Group Policy Object
Model.vbs :
'-------------------------
' Created 3/29/2011
' When used as login script it will populate the Computer Description
' in Active Directory with UserName, Serial Number & Computer Model
' --------------------------
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colcomputersystem = objWMIService.ExecQuery _
("Select * from Win32_computersystem")
Set colBIOS = objWMIService.ExecQuery _
("Select * from Win32_BIOS")
For each objcomputersystem in colcomputersystem
Getcomputersystem = objcomputersystem.Model
Next
For each objBIOS in colBIOS
GetSerialNumber = objBIOS.SerialNumber
Next
Set objSysInfo = CreateObject("ADSystemInfo
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
strMessage = objUser.CN & " / " & GetSerialNumber & " / " & Getcomputersystem
objComputer.Description = strMessage
objComputer.SetInfo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My thanks to the both of you!
This is an awesome coding utility. It's like a wizard that can write your WMI code in multiple languages (vbscript, perl, etc) and use a few different output formats, just by clicking a radio button.
If you don't have it, you have to download if you're using WMI scripts.
Go here: http://www.computerperformance.co.uk/vbscript/wmi_scriptomatic.htm
There's a download link and brief sample explanation.
Run that on your 2008 server!