Jump to content


h4x0r

Not just another "how do I prompt for computer name" thread ;)

Recommended Posts

This is mostly for people familiar with MDT scripting/integration...

 

I've been working on this non-stop today trying all sorts of methods to try and accomplish a prompt for computer name at a specific point...I'm certain that it can be done, but I'm losing hope! :P

 

Here's the scenario...I'm using Maik Koster's web service (v7.3), as well as his custom boot image for OSD, with MDT 2012 integration. With the custom boot image, the pre-execution mediahook runs and performs a series of webservice calls to populate a wizard that allows for TS selection. After the selection is made, it adds the computer to the appropriate collection with the OSD TS and off you go! This works GREAT for known computers...unknown computers are a little different. I can boot unknown computers to the custom boot wizard, and they get added to whichever collection and are added to the server at the same time. HERE IS THE ODDITY: the computers get added with their MAC address as the computer name, as opposed to MININT-######

 

I've added a successful check in the pre-execution hook to test if the computer is known or not...if it is unknown, then a simple prompt comes up and we can put in the computer name. THE PROBLEM is that I have NO IDEA what variable I'm supposed to set with the input. The pre-execution hook calls ZTIGather and ZTIUtlity...I've tried setting oEnvironment.Item("OSDComputerName")/("HostName") to the input gathered previously...but it didn't change anything (the webservice call is SUPPOSED to use OSDComputerName as the name)...I'm honestly stumped as to what variable I need to set (since it is using the MAC address for the name), OR would be more viable to try and set a (environmental?) variable that the SCCM_Bootstrap.ini/Customsettings.ini uses? For instance the existing webservice call in the ini file looks like this:

 

-----------------------------------------

 

[AddComputerToCollection]

WebService=http://YourWebServer/Deployment/SCCM.asmx/AddComputerToCollection

Parameters=MACAddress,UUID,CollectionID,ComputerName

MACAddress=macAddress

UUID=UUID

CollectionID=collectionID

ComputerName=Computername <-- THIS IS NOT POPULATED FOR SOME REASON

------------------------------------------

 

would it be possible to do something such as:

 

-------------------------------------------

MyNewCustomVariable=%SetByScript%

 

 

[AddComputerToCollection]

WebService=http://YourWebServer/Deployment/SCCM.asmx/AddComputerToCollection

Parameters=MACAddress,UUID,CollectionID,ComputerName

MACAddress=macAddress

UUID=UUID

CollectionID=collectionID

MyNewCustomVariable=Computername

 

--------------------------------------------

 

I guess that it might be possible that SCCM is inserting the MAC address to use as the computer name since/if it isn't being provided...but that thought just occurred to me, and I haven't had a chance to look into that possibility. This is all very new to me, as I'm not super familiar with the workings of MDT scripting/customizations. When I get back to work in the morning, I'm going to go through the logs again and see if/where I missed the section that is using the MAC address for the computer name.

 

Hopefully, if I can get this working, then I'll have a very handy method for imaging bare metal workstations with a computer name prompt tied in :)

Share this post


Link to post
Share on other sites


shouldn't it be OSDComputerName,

checkout my example of doing just this here

 

How can I easily prompt for a computer name in Configuration Manager 2012

Prompting for a computer name using the OSDComputerName variable [May 11th, 2012].

Share this post


Link to post
Share on other sites

It SHOULD be (as a side note, that's what we use to prompt for a name while we don't have the boot wizard up and running fully yet), but I think one of the caveats is that due to the nature of the pre-execution hook, that OSDComputerName variable on the Unknown Computers collection is never created since the webservice ends up creating a DDR for the computer and adding it to the collection selected. I guess a possible way around that would be to duplicate all my OSD collections and simply have a set for unknown computers with the OSDComputerName set...but that wouldn't be as streamlined as I would like :P

 

I'm going to have a look now at the logs, and also play around with how I can set variables for use with the customsettings.ini to see if that has any effect.

Share this post


Link to post
Share on other sites

If you want to use the MAC Address as the computer name you could use this line in the default section of your customsettings.ini file.

You could also tweak this a little bit more by replacing the PC prefix for Laptops.

 

OSDComputerName=PC#Replace("%MacAddress001%",":","")#

Share this post


Link to post
Share on other sites

Unfortunately, workstation names go by specific locations and room numbers...so using the MAC address is out of the question.

 

As of right now, I believe that it was SCCM using the MAC address as the computer name when the DDR was getting created by the webservice, since a name wasn't being provided.

Share this post


Link to post
Share on other sites

Well, in this case you might consider to use the MDT database feature of MDT2012 to assign computer names.

Share this post


Link to post
Share on other sites

Have some issues with Maik's web service as well. OSDComputerName is not carried through the rest of the TS and is not applied. I'm using his PrettyGoodFrontendClone. Also, if the computer is unknown to SCCM and then added to an OSD collection, it waits for all 25 tries under the HasOSAdvertisement step outlined in the CustomSettings.ini file. After a few minutes it shows up in the correct collection when I look in the console. But it obviously takes too long.

 

We use this exact web service and frontend in our current SCCM 2007 production environment. But in the 2012 lab environment it just won't work.

 

Any ideas?

Share this post


Link to post
Share on other sites

There apparently is some sort of bug with his webservice where adding an unknown computer will create an entry for it, but it doesn't get "completely" added to SCCM for a few minutes...thus it sits through the number of cycles waiting for HasOSAdvertisement. We don't use the PrettyGoodFrontendCline...we just use the custom boot wizard. What I ended up doing was modifying part of the HTA wizard in a couple ways. One was to add a bit of user security and so I have a password field set, which if entered incorrectly after three tries will simply reboot the computer, or if the wizard is canceled it will also reboot. The second is to run another webservice call for IsComputerKnown, and if it returns false then I stop the script from continuing and it then dumps the computer right into the standard TS GUI. From there I select our deploy OS TS, and because it is deployed to the Unknown Computers collection, we have to set the OSDComputerName variable...so that's when it gets prompted for the name, AND gets added to SCCM correctly.

 

Unfortunately I just wasn't able to find a smoother way of adding unknown computers simply using Maik's webservice.

Share this post


Link to post
Share on other sites

Thanks for the info! Are admins/MVPs running SCCM 2012 just not using web services? Can't seem to find any information about this on the internet when it comes to 2012. Plenty of info for 2007 but that doesn't really help in this case.

 

I would really appreciate if you could paste the code from your customizations, if that would be alright?

Share this post


Link to post
Share on other sites

We are one child of many in our AD stucure, and there are quite a few others who I know are using SCCM in the same forest, but I dont think many of them use webservices (I may be one of only a few). From what I understand, the web services still function the same with 2012 as they did with 2007, so I'm not too surprised that there isn't much out there in the way of using them with 2012 since it is nearly identical to using them with 2007 (but I could be wrong about this, too!)

 

I'll try to post the code for the custom boot wizard's HTA and such that we use, but it may take me a bit as I'm presently at work and have a couple items that need my attention ;)

Share this post


Link to post
Share on other sites

Yeah, it seems like web services in of themselves shouldn't differ a whole lot :)

 

Whenever you have time. Really appreciate it.

Share this post


Link to post
Share on other sites

Sorry for the delay...things got bogged down here and I haven't had the time to get back to you. Here are our modified wizard.hta and ZTIMediaHook.wsf files modified files.zip. Items of note:

 

Wizard.hta -- there are a few sections I added to this file...since if we're using it, then it means that one of our techs is on site to image the computer (otherwise we're just imaging it remotely and not using the boot wizard). The first section that differs from Maik's HTA are a few sub routines that I added to prevent the wizard from being closed and WinPE continuing as normal. Secondly, is a quick password validation field...this just uses a simple encryption function to match the input from the password field (you'll need to run the function in its own script so you can get the encrypted string of your designated password). Without the password, then the end user cannot select a TS from the menu. Ultimately this is not something that I am terribly worried about keeping ultra-secure. If a user REALLY wants to try and hack it, then that's fine...they can image their computer and likely lose all their data in the process...the password verification is really more of an idiot prevention measure.

 

ZTIMediaHook.wsf -- I addded a couple extra web service calls to this...most noteably is the IsComputerKnown call. This runs AFTER the wizard has been processed, but before any checks are made for HasOSDAdvert, simply so that users cannot boot an unknown computer and pull down our image (the wizard requires the password input).

 

We have a single TS for our image deployment (and use the custom boot wizard boot image as the boot image with all deployments), with multiple Apply OS steps being dependant on various TS variables (namely related to which image is to be used). In this scenario, we have this TS being deployed to our Deploy XX OS containers, as well as the Unknown Computers container. On our Unknown Computers container we have have the OSDComputerName variable present but blank. The end result here is that when a known computer boots into the wizard, then we can select whichever deployment we want and continue as normal, and if it is unknown then it kicks out of the wizard and proceeds directly to the normal TS menu. Being unknown, we select the TS that is deployed to the Unknown Computers container, and then proceed to fill in needed variables such as OSDComputerName. The computer gets added to SCCM correctly (thus preventing the bug with the delay of being added via the web service), and is still prompted for a computer name.

 

Hope this helps!

 

modified files.zip

Share this post


Link to post
Share on other sites

I've also modified it to extract DELL's asset bios label, and I use that information for SCCM's variable.

Share this post


Link to post
Share on other sites

This is what I use in my TS right after partitioning.

 


' vbscript
' Declare Variables
Dim strCampus
Dim strSerialNum
Dim strAppend
Dim strComputerName
Dim strLclUser
Dim strLclPW
Dim strComputer
Dim objWMIService
Dim objComputer

' Set Variables
SET env = CreateObject("Microsoft.SMS.TSEnvironment")
strLclUser = "Administrator"
strLclPW = "adminpassword"

'Prompt For Campus
strCampus = INPUTBOX("Enter Campus Name")

'Prompt For Teacher Or Student
strAppend = INPUTBOX("Enter Teacher Or Student")

' Obtain Serial Number
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")

For Each objSMBIOS in colSMBIOS
strSerialNum = objSMBIOS.SerialNumber
Next

' Set Computer Name
strComputerName = strCampus & "-" & strSerialNum & "-" & strAppend

'Set OSD Computer Name Variable
env("OSDComputerName") = strComputerName

'End Script

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