Solved

Case Statement - VB/WMI Script / Need formatting help/advice

Posted on 2004-04-22
1
424 Views
Last Modified: 2013-12-03
Hi,

I am trying to get a fully automated solution for deploying machines I manage in our department.  I was going to try and write a WMI script that would get the MAC address, query the database, and name it appropriately.  We use static machine names and ip addresses.  I have virtually no experience in programming and would like some help/advice with the following:

Dim strMac
Dim NewComputerName
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
For Each objItem in colItems
If objitem.Manufacturer = "Broadcom" or objitem.Manufacturer = "Linksys" Then
     strMac = objItem.MACAddress
End If
Next

***Can I put a case statement somewhere here where I can say if strMac = "blah" then NewComputerName = "blah"?***


Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
    err = ObjComputer.Rename(NewComuterName)
    Wscript.Echo err
Next


I only have about 25 machiens or so and they are split up between three images, so there would only be a max of 10 choices for each image.  Would this be the easiest way to name the machine to a predetermined static machine name?

Thanks in advance!


0
Comment
Question by:jkrech17
1 Comment
 
LVL 8

Accepted Solution

by:
KerryG earned 500 total points
ID: 10891175
Are you looking for something like this:

select case strMac
    case "0000aaaabb"
      NewComputerName = "machine1"
    case "000bbbbbbb"
      NewComputerName = "machine2"
end select
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question