cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Re: Who uses the custom property fields and for what?

Ok, So I wrote my own to do this.  The script will wmi query the make, model, serial and also the Chassis type.  I added the Chassis type because EPO misdetects very badly if a computer is a laptop or not.  Im guessing they query on battery presence which gives many desktops false detect.  I chose to use Chassis type as it is more accurate.  You can either use the default values for Chassis type or change the ones you want to either Laptop or Desktop if you dont want all the different values.  Im sure the script could be cleaned up quite a bit as I threw this together from many of my other scripts and just got it working.  If you clean it up or improve it I would greatly appreciate you reposting it.  If you test on Vista or 7 remember to execute the script through a command prompt eleevated as administrator.

------------------------------------------------------------------------------------------------------

'Create Custom Properties to pull Make, Model, Serial and Type in EPO
'created by: Daniel VanMeter
'
'
On error resume next


strComputer = "."


Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystem",,48)
For Each objItem in colItems
Model = objItem.Model

Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_BIOS",,48)
For Each objItem in colItems
Company = objItem.Manufacturer
Serial = objItem.SerialNumber

Next

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colChassis = objWMIService.ExecQuery _
    ("Select * from Win32_SystemEnclosure")
For Each objChassis in colChassis
    For  Each strChassisType in objChassis.ChassisTypes
        Select Case strChassisType


            Case 1
            CaseType ="Other"
            
            Case 2
            CaseType ="Unknown"
              
            Case 3
            CaseType ="Desktop"
             
            Case 4
            CaseType ="Low Profile Desktop"
              
            Case 5
            CaseType ="Pizza Box"
             
            Case 6
            CaseType ="Minitower"
               
            Case 7
            CaseType ="Tower"
              
            Case 8
            CaseType ="Portable"
              
            Case 9
            CaseType ="Laptop"
             
            Case 10
            CaseType ="Notebook"
             
            Case 11
            CaseType ="Handheld"
             
            Case 12
            CaseType ="Docking Station"
              
            Case 13
            CaseType ="All-in-One"
            
            Case 14
            CaseType ="Sub-Notebook"
            
            Case 15
            CaseType ="Space Saving"
             
            Case 16
            CaseType ="Lunch Box"

            Case 17
            CaseType ="Main System Chassis"
           
            Case 18
            CaseType ="Expansion Chassis"
             
            Case 19
            CaseType ="Sub-Chassis"
            
            Case 20
            CaseType ="Bus Expansion Chassis"
            
            Case 21
            CaseType ="Peripheral Chassis"
             
            Case 22
            CaseType ="Storage Chassis"
              
            Case 23
            CaseType ="Rack Mount Chassis"
          
            Case 24
            CaseType ="Sealed-Case PC"
              
            Case Else
            CaseType ="Unknown"
              
            End Select
    Next

Next

const HKEY_LOCAL_MACHINE = &H80000002

Set StdOut = WScript.StdOut

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Network Associates\ePolicy Orchestrator\Agent\CustomProps"

oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath

strKeyPath = "SOFTWARE\Network Associates\ePolicy Orchestrator\Agent\CustomProps"

strValueName = "CustomProps1"

strValue = Company

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

strValueName = "CustomProps2"

strValue = Model

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

strValueName = "CustomProps3"

strValue = Serial

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

strValueName = "CustomProps4"

strValue = CaseType

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

---------------------------------------------------------------------------------------------------------------------------

Message was edited by: Dvanmeter on 8/29/10 5:59:18 PM CDT

Re: Who uses the custom property fields and for what?

looks like from pushing this out EPO misdetects the chassis "lunchbox" as a laptop.  We have about a thousand desktops listed as laptops because of this.  I guess we will start using the customprops4 field in my script to base this info off of now.

Re: Who uses the custom property fields and for what?

as it turns out we already have the information I want to put in epo in a seperate location in the registry. Is there any way to get the agent to look in a key other than network associates\customprops\?

broot
Level 9
Report Inappropriate Content
Message 24 of 50

Re: Who uses the custom property fields and for what?

I'm afraid not. However, you should be able to create a script to copy those key values into the CustomProps keys. Then, the Agent will pick them up on the next Agent-server communication and report to ePO.

-Brad

Re: Who uses the custom property fields and for what?

3300 machines across multiple forests and growing daily:-(

Re: Who uses the custom property fields and for what?

One thing to make this easy is to turn the vbscript i wrote into an exe (Easily done with winrar).  The use the function in epo to run the exe after a dat file update attempt. This will take care of all of your systems that can access the unc path you specify without user interaction.  worked well for us.

Re: Who uses the custom property fields and for what?

Dvanmeter wrote:

Ok, So I wrote my own to do this.  The script will wmi query the make, model, serial and also the Chassis type.  I added the Chassis type because EPO misdetects very badly if a computer is a laptop or not.  Im guessing they query on battery presence which gives many desktops false detect.  I chose to use Chassis type as it is more accurate.  You can either use the default values for Chassis type or change the ones you want to either Laptop or Desktop if you dont want all the different values.  Im sure the script could be cleaned up quite a bit as I threw this together from many of my other scripts and just got it working.  If you clean it up or improve it I would greatly appreciate you reposting it.  If you test on Vista or 7 remember to execute the script through a command prompt eleevated as administrator.

------------------------------------------------------------------------------- -----------------------

'Create Custom Properties to pull Make, Model, Serial and Type in EPO
'created by: Daniel VanMeter
'
'
On error resume next


strComputer = "."


Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystem",,48)
For Each objItem in colItems
Model = objItem.Model

Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_BIOS",,48)
For Each objItem in colItems
Company = objItem.Manufacturer
Serial = objItem.SerialNumber

Next

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colChassis = objWMIService.ExecQuery _
    ("Select * from Win32_SystemEnclosure")
For Each objChassis in colChassis
    For  Each strChassisType in objChassis.ChassisTypes
        Select Case strChassisType


            Case 1
            CaseType ="Other"
            
            Case 2
            CaseType ="Unknown"
              
            Case 3
            CaseType ="Desktop"
             
            Case 4
            CaseType ="Low Profile Desktop"
              
            Case 5
            CaseType ="Pizza Box"
             
            Case 6
            CaseType ="Minitower"
               
            Case 7
            CaseType ="Tower"
              
            Case 8
            CaseType ="Portable"
              
            Case 9
            CaseType ="Laptop"
             
            Case 10
            CaseType ="Notebook"
             
            Case 11
            CaseType ="Handheld"
             
            Case 12
            CaseType ="Docking Station"
              
            Case 13
            CaseType ="All-in-One"
            
            Case 14
            CaseType ="Sub-Notebook"
            
            Case 15
            CaseType ="Space Saving"
             
            Case 16
            CaseType ="Lunch Box"

            Case 17
            CaseType ="Main System Chassis"
           
            Case 18
            CaseType ="Expansion Chassis"
             
            Case 19
            CaseType ="Sub-Chassis"
            
            Case 20
            CaseType ="Bus Expansion Chassis"
            
            Case 21
            CaseType ="Peripheral Chassis"
             
            Case 22
            CaseType ="Storage Chassis"
              
            Case 23
            CaseType ="Rack Mount Chassis"
          
            Case 24
            CaseType ="Sealed-Case PC"
              
            Case Else
            CaseType ="Unknown"
              
            End Select
    Next

Next

const HKEY_LOCAL_MACHINE = &H80000002

Set StdOut = WScript.StdOut

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Network Associates\ePolicy Orchestrator\Agent\CustomProps"

oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath

strKeyPath = "SOFTWARE\Network Associates\ePolicy Orchestrator\Agent\CustomProps"

strValueName = "CustomProps1"

strValue = Company

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

strValueName = "CustomProps2"

strValue = Model

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

strValueName = "CustomProps3"

strValue = Serial

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

strValueName = "CustomProps4"

strValue = CaseType

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

-------------------------------------------------------------------------------- -------------------------------------------

Message was edited by: Dvanmeter on 8/29/10 5:59:18 PM CDT

I've used your script as a starting point for my own version and I have it working well on XP 32-bit machines with no issues however when I attempt to run this on a Windows 7 64-bit machine it does not function as it should.  Is there code in this that only applies to 32-bit OS's possibly the WMI/BIOS queries ?  You would think it would still create the registry key even if the values were not populated with any data.  Bottom line is that I am seeing inconsistant behavior with this on Windows 7 it did work on one machine I believe but if you could possibly provide any input or ideas on getting this working on Windows 7 64-bit machines it would be much appreciated!

Re: Who uses the custom property fields and for what?

I havent had any problems with Windows 7.  It has ran successfully on over 1000 Windows 7 x64 computers.  The difference may be how we are deploying it.  I use winrar to bundle the script within an exe.  I then use the feature in the Mcafee agent that allows you to run a exe after a dat file update or attempt.  I just place the exe then on a server that most users can get to.   The only time this doesnt work is if someone isnt logged into the computer and the server the exe resides on requires authentication.  You could push the script via active directory and add some logic that says if     hklm\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent\CustomProps\CustomProps1 does not exist then run script.  Or you could use Landesk/SMS/Zenworks ect. and it should run it.

My point is I dont think the script is the problem, I think it has to do with permissions in Windows 7 or with the account its running under.  Let me know how it works out.  If you would like me to send you the script in EXE format, let me know.

Message was edited by: Dvanmeter on 8/12/11 11:10:14 AM CDT

Message was edited by: Dvanmeter on 8/12/11 11:13:20 AM CDT

Re: Who uses the custom property fields and for what?

Thanks for the quick reply, it could always be an issue with my code but I'm a bit baffeled why it's working fine on my XP machines so I don't think that is the case.  Right now I haven't began to deploy it to the masses, just doing some testing by manually executing the .vbs file on a few different types of machines.  I am an administrator on both the XP and Windows 7 machines so I'm not sure what the issue is, possibly something with user account control?? The Win7 machine I'm testing it on I have both my domain account and local account in the local admin group so i'm a bit baffled on what the deal is.

Re: Who uses the custom property fields and for what?

Does the code I wrote work, or does it also fail.  Try opening a command prompt by right clicking on cmd.exe and run it as an administrator.  Then execute the vbscript inside the command prompt.  See if that works.

More McAfee Tools to Help You

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community