Jump to content


adz

SCCM + VMWare - Computer naming

Recommended Posts

Hi all,


I currently am working on client site, and I've been requested to research the possibility of renaming a VMWare virtual machine computer name using a step in an SCCM 2012 Task Sequence.


The idea is this:


1. Using a script to obtain the MAC address of the virtual machine

2. Once it has the MAC address, using the same or another script to query the VCenter database using PowerCLI or similar to find that MAC address to then find the VM friendly name, to then change the NETBIOS name of the deployed & domain joined machine.


This is all to alleviate having to type in the VMWare virtual machine friendly name, and the NETBIOS name (OSDComputerName)....an attempt in reducing double handling.


I've seen a few scripts floating around on the interwebs, but nothing substantial or overly specific to what I'm looking for.

Share this post


Link to post
Share on other sites

Hi,

I know this is pretty old, but just in case someone needs it:

Dim env
Dim strCPUName

strNewName = "wrongname" 

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery ("Select SerialNumber from Win32_SystemEnclosure") 

For Each objSMBIOS in colSMBIOS 
	strNewName = objSMBIOS.SerialNumber
Next

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration WHERE IPENABLED = 'True'")
For Each objItem in colItems
	strMAC = Replace(ObjItem.MACAddress, ":","")
	strCPUName = "V" & Right(strMAC,7)
	If Len(strCPUName) > 1 Then
	    	Exit For
	End If
	Next

Set env = CreateObject("Microsoft.SMS.TSEnvironment") 
env("COMPUTERNAME") = strCPUName

after this you'll need to set a Task Sequence variable OSDCOMPUTERNAME to %COMPUTERNAME%

 

thats it. :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.