[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-04-22
1
Medium Priority
?
432 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 2000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

872 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