Jepeto 46 Posted June 6, 2013 Report post Posted June 6, 2013 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. Quote Share this post Link to post Share on other sites More sharing options...
0 Peter van der Woude Posted June 6, 2013 Report post Posted June 6, 2013 What's the problem you are running into? Where do you use this script (in the task sequence)? Quote Share this post Link to post Share on other sites More sharing options...
0 Jepeto 46 Posted June 6, 2013 Report post Posted June 6, 2013 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. Quote Share this post Link to post Share on other sites More sharing options...
0 Peter33 Posted June 6, 2013 Report post Posted June 6, 2013 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. Quote Share this post Link to post Share on other sites More sharing options...
0 Jepeto 46 Posted June 6, 2013 Report post Posted June 6, 2013 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. Quote Share this post Link to post Share on other sites More sharing options...
0 Peter33 Posted June 7, 2013 Report post Posted June 7, 2013 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. Quote Share this post Link to post Share on other sites More sharing options...
0 Jepeto 46 Posted June 7, 2013 Report post Posted June 7, 2013 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. Quote Share this post Link to post Share on other sites More sharing options...
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
<><><><><>
Share this post
Link to post
Share on other sites