Jump to content


  • 0
madmattwall

OSDComputername variable for setting computer name

Question

hi all,

 

i am running the following script to pull the machine name from the SMBIOS for the ZTI deployment of windows 7.

 

the problem i have it works fine for any DELL PC we have but not on our Viglen Range.

 

if you run the script on a built Viglen PC it comes back with the relevant information. so i know my script is running OK.

 

i have added this to run as a package in my MDT Task Sequence within Config Manager at the beginning of the post install phase just before the Gather Process.

 

has anyone else had any problems auto pulling the machine name on a viglen into SCCM.

 

i have tried numerous things but it is being a pain in the arse.

 

any help would be greatly received.

 

cheers

 

Matt

 

here is the vbscript I'm running

 

dim env
strNewName = ""
strManName = ""
Set objWMIService = GetObject("winmgmts:" _ 
  & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2") 

Set colSMBIOS = objWMIService.ExecQuery _ 
  ("Select * from Win32_ComputerSystemProduct") 
For Each objSMBIOS in colSMBIOS 
strManName = objSMBIOS.Vendor 
Next


If strManName = "Dell Inc." then
	Set colSMBIOS = objWMIService.ExecQuery _ 
  		("Select * from Win32_SystemEnclosure") 
	For Each objSMBIOS in colSMBIOS 
		strNewName = objSMBIOS.SerialNumber
	Next 

ElseIf strManName = "Viglen" then
	Set colSMBIOS = objWMIService.ExecQuery _ 
  		("Select * from Win32_SystemEnclosure") 
	For Each objSMBIOS in colSMBIOS 
		strNewName = objSMBIOS.SMBIOSAssetTag 
	Next

ElseIf strManName = "TOSHIBA" then
	Set colSMBIOS = objWMIService.ExecQuery _ 
  		("Select * from Win32_BIOS") 
	For Each objSMBIOS in colSMBIOS 
		strNewName = objSMBIOS.SerialNumber
	Next 
End if

SET env = CreateObject("Microsoft.SMS.TSEnvironment") 
env("OSDComputerName") = strNewName

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I’ve sorted this out, the Viglen machines serial number is all numeric and windows 7 has to have an alpha numeric name, i knew it would be something annoying that was causing us issues.

 

im now making the script check for which chassis is reported from WMI so that it can then assign certain prefixes based mobile devices and desktops. so no doubt ill be posting something again soon for some input / help, LOL

Share this post


Link to post
Share on other sites

  • 0

Sorry for bringing up an old thread, when I try this script in my Task Sequence it didn't work.

 

I tested it on my Dell desktop prior and it was able to pull the serial. When I updated the DPs with this and tried it the pop up window didn't contain the serial tag.

 

Did you place your script before or after the partition task or it doesn't really matter?

 

Edit: I figured out the problem, I've made my script pre-fill the serial number in the inputbox and used the wrong variable. All good now.

 

Here's my modified script of the OP and others I found which will prefill an input box with the service tag. In my environment, we add the state, site code, and dash before the service tag. This will save you from having to flip the laptop and reading the small stickers or bend down in someone's nasty cubicle to read it. Our environement is 100% Dell so I can only confirm it works on Dell systems.


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

For Each objSMBIOS in colSMBIOS 
strserial = objSMBIOS.SerialNumber
Next 

default=strSerial

sNewPCName = InputBox ("Please enter a computer name to continue." & Chr(13) & Chr(13) & "Serial Tag:  " & strSerial, "Computer Name", default, 30,30)

env("OSDComputerName") = SNewPCName
env("ComputerName") = SNewPCName 
env("HostName") = SNewPCName

Share this post


Link to post
Share on other sites

  • 0

Glad this helped you out and the extra info is great thanks.

 

My headache is still with getting this script working over multiple vendors and but also by identifying the chassis first then give it the correct name based on mobile device or desktop.

 

Would love to go with one naming convention but unfortunately in our case we can’t.

 

Let me know if you do any other work on this topic great to hear about others using or developing this.

:)

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
Answer this question...

×   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.