Link to home
Start Free TrialLog in
Avatar of eltel-it-nor
eltel-it-norFlag for Norway

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=impersonate}!\\" & 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
ASKER CERTIFIED SOLUTION
Avatar of Miguel Angel Perez Muñoz
Miguel Angel Perez Muñoz
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Although not a direct answer to your query...but have you ever used Scriptomatic 2.0 ?
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!
Avatar of eltel-it-nor

ASKER

My thanks to the both of you!