Jump to content


  • 0
Jepeto 46

Setting computer name during OSD

Question

We are consolidating and renaming, I have a script which does not seem to work:

We want to base the OSDComputerNAme based on the current hostname, not where the computer is deployed from.

Here is the script

<><><><><>

'On Error Resume Next
Dim strComputer, newName
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
'wscript.echo strComputer & " " & objSMBIOS.SerialNumber
Select Case UCase(Left(strComputer,2))
Case "NY" newName = "HQ-" & objSMBIOS.SerialNumber
Case "NI" newName = "HQ-" & objSMBIOS.SerialNumber
Case "NM" newName = "HQ-" & objSMBIOS.SerialNumber
Case "LA" newName = "WE-" & objSMBIOS.SerialNumber
Case "AZ" newName = "WE-" & objSMBIOS.SerialNumber
End Select
wscript.echo newName
SET env = CreateObject("Microsoft.SMS.TSEnvironment")
env("OSDComputerName") = NewName
Next
<><><><><><>
Any help greatly appreciated.
Thank you.

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Peter

Thanks for looking

I placed the script right before the Apply operating system. Everything worked fine when testing, I think that the deploying tech deployed with a USB key, so the script simply did not apply, I am still trying to find out what happened.

I would prefer to do all of it with MDT (currently integrated with my SCCM 2012) however I have some complex scenario.

Share this post


Link to post
Share on other sites

  • 0

Hmm, this can't work. You are trying to query the AD during the PE Phase, when your Computer is not an AD member. Rather use a webservice (Maik Kosters is pretty good) to query the netbootGUID of the compuer object. This way you can retrieve the corresponding Computer Name. You can also query the SCCM database for the MAC address, which would be an Option too, to get the correct Name.

The MDT can help you there too. You can build the Computer Name directly with the customsettings.ini.

Your case select section is also missing two cases for reimaging. When your new Computer names are already set to either HQ or WE.

Share this post


Link to post
Share on other sites

  • 0

Thanks for the great comments, yes, I do miss two cases...never thought about the re-imaging part.

I am not sure I understand the part of "can't work". Are you referring to the key or the bootable USB? How about if I place the script in the Refresh only section?

The goal is simple, if we refresh than have the script or MDT DB determines the name, and if bootable media than the ability to select the name, which I found what I need here

http://blogs.technet.com/b/deploymentguys/archive/2011/08/05/dynamic-computer-naming-in-zti-deployments-using-mdt-and-configmgr.aspx

 

UPDATE: the script actually works it should be in the Refresh Only. All that is left for me now is to implement the location based install.

Share this post


Link to post
Share on other sites

  • 0

Yes, i was referring to PXE and Media boots. You hostname will be always MININT there.

You should think about a single shot solution for the computer naming part. No reason to go with two solutions for the same task.

Share this post


Link to post
Share on other sites

  • 0

I agree on a single solution, problem is MDT does not see to identify the host name in a way I can use it a in a subsection, or I simply do not know how to do it :-)

UPDATE: I solved the issue using the script above and the MDT DB + UDI screen for new computers. thanks for helping me sorting this out and giving a direction.

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.