locked
Ability to save exiting name or create a new name RRS feed

  • Question

  • Right now in my CS I have it setup to auto name the PC's based off serial number like this:

    [Laptop-True] OSDComputername=PSYL-#Right("%SerialNumber%",10)# MachineObjectOU=OU=Laptops,OU=Computers,DC=MYCOMPANY,DC=SOMEWHERE,DC=COM [Desktop-True] OSDComputername=PSY-#Right("%SerialNumber%",11)# MachineObjectOU=OU=Computers,DC=MYCOMPANY,DC=SOMEWHERE,DC=COM

    This works fine but now I have the request on certain computers to retain the old name. I was able to do this with a VBS script I found and set my CS to this but removing the above lines about the ComputerName:

    [Default]
    UserExit=retainPCname.vbs
    OSDComputername=#GetOfflineComputername()#

    This also works fine but I need to combine these 2 with some sort of click option on the Computer Name panel

    I know you can make/edit the panels but I am just not sure how to do that in this scenario or what the best way would be.

    Thanks,

    Scott

    Monday, October 30, 2017 1:38 PM

Answers

  • The high-level steps to enable BitLocker during a TS are:

    • make sure TPM is on and activated
    • (optional) enable pre-provisioning
    • if TPM module had been used before, clear it
    • Enable BitLocker

    If you need assistance, please open a new thread, so that we can keep some resemblance of a structure here. :)

    Back to topic: again, this is the high-level approach:

    To store ownership tag in the BIOS:

    On Dell systems:

    1. Install HAPI drivers:

    hapint64.exe -i -k C-C-T-K -p "hapint64.exe" -q


    2. Set Ownership tag

    cctk.exe --propowntag="Hostname" --valsetuppwd=Password

    On HP systems:

    Note: Depending on HW generation, BIOS property name may be called differently.

    There is just one step if you are using BiosConfigUtlity:

    BiosConfigUtility64.exe /SetValue:"Ownership Tag","Hostname" /CurSetupPasswordFile:"password.bin"'

    You could wrap this into a PowerShell script and pull data from SMS TS environment (primarily OSDComputerName value).  I typically run the script inside of Windows PE at the beginning of a TS (in case TS fails the device will carry over assigned computer name for subsequent reinstalls).

    To pull data from BIOS, I would recommend using a UserExit script during the initial Gather process:

    Here is an example how to pull data from HP BIOS using a UserExit script:

    Case "HEWLETT-PACKARD", "HP"
             oLogging.CreateEntry "USEREXIT:Make = HP", LogTypeInfo ' connect to the HP WMI provider strService = "winmgmts:{impersonationlevel=impersonate}//" strComputer = "." strNamespace = "/root/HP/InstrumentedBIOS" strQuery = "select * from HP_BIOSSetting" On Error Resume Next Set objWMIService = GetObject(strService & strComputer & strNamespace) Set colItems = objWMIService.ExecQuery(strQuery,,lFlags) If Err then oLogging.CreateEntry "Error querying HP_BIOSSetting: " & Err.Description & " (" & Err.Number & ")", LogTypeError Else Counter = 1 For Each objItem In colItems If (objItem.Name = "Ownership Tag") Then If objItem.Value <> "" Then SetComputerNameAlias = objItem.Value oLogging.CreateEntry "USEREXIT:ComputerNameAlias set to " & SetComputerNameAlias, LogTypeInfo Else oLogging.CreateEntry "USEREXIT:ComputerNameAlias is empty.", LogTypeInfo

    End If End If Counter = Counter + 1 Next End If


    On Dell systems, I would go down the cctk route: read the value of the Ownership Tag, filter the result, assign the value if not empty, otherwise CustomSettings.ini evaluation will proceed and a computer name will be created based on your rules.


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".


    • Edited by Anton Romanyuk Tuesday, October 31, 2017 7:19 AM code formatting
    • Marked as answer by swindmiller Thursday, November 2, 2017 11:08 AM
    Tuesday, October 31, 2017 7:18 AM
  • Dan_Vega,

    That would be great! Do you want me to start a new topic, reach out privately or post here?

    Anton,

    Thanks for the info on the Welcome.xml. After playing around with the Wizard Editor I am learning alot with how everything works. I came up with a way that will work great for us, and dropped the extra page to pick New Computer or Reimage. I made the changes on the actual Computer Name page.

    I have that VBS I mentioned earlier for capturing the existing computer name (retainPCname.vbs).

    I added this to the customsettings.ini to basically set a variable with the existing computer name and new computer name, regardless if they are used or not.

    UserExit=retainPCname.vbs
    
    OSDComputernameExisting=#GetOfflineComputername()#
    
    OSDComputernameNew=PSY-#Right("%SerialNumber%",11)#


    I added this section to the DeployWiz_ComputerName.xml file:

    <table style="width: 100%;">
    	<tr>
    			<td style="width:57px;">
    		</td>
    		<td>
    			<input type=radio name="ComputerNameSelect" id="CNRadio1" language=vbscript onclick=ValidateComputerNameSelect>
    			Reimage - Attempt to detect the computer's existing name, and use it as the new computer name.
    			<br></br>
    			<input type=radio name="ComputerNameSelect" id="CNRadio2" checked language=vbscript onclick=ValidateComputerNameSelect>
    			New Image - Use the computer's serial number to generate the computer name.
    			<br></br>
    			<br></br>
    			<br></br>
    		</td>
    	</tr>
    	</table>

    And this section to the DeployWiz_ComputerName.vbs file:

    Function ValidateComputerNameSelect
    	' Check Warnings
    	ParseAllWarningLabels
    	
    	If CNRadio1.checked then
    		OSDComputerName.Value = oEnvironment.Item("OSDComputerNameExisting")
    		ValidateComputerNameSelect = TRUE
    	ElseIf CNRadio2.checked then
    		OSDComputerName.Value = oEnvironment.Item("OSDComputerNameNew")
    		ValidateComputerNameSelect = TRUE
    	End if
    End Function

    This will allow them to go back and forth with using the radio buttons if they need to. Works great in testing but have to double check. Thanks for all your help!

    Scott




    • Marked as answer by swindmiller Thursday, November 2, 2017 11:07 AM
    Wednesday, November 1, 2017 6:14 PM

All replies

  • Keep in mind that this approach will not work if you opt to use BitLocker drive encryption, so I usually just put current computer name into the Ownership Tag in the BIOS and then query BIOS using a UserExit script.

    If that is not a concern in your case...

    First, try to query offline system - if it is empty or does not match your naming convention, do not set OSDComputerName variable. This will allow your CustomSettings rules to kick in and set the OSDComputerName (Note: during CustomSettings.ini processing, the variable OSDComputerName will be set once, which allows implementing the approach I described above).

    You could, of course, go for a more complicated route and implement some sort of querying mechanism into your UI, but the approach I described above might be sufficient in your case...



    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Monday, October 30, 2017 4:54 PM
  • Thanks Anton! We do plan to use Bitlocker at some point but it's not working properly on all models anyway so I have not implemented it yet. If you or anyone has an sample of the code that would use this logic it may help me to manipulate it for myself. Thanks for replying back, Scott
    Monday, October 30, 2017 9:35 PM
  • Which manufacturers are we talking about? I could provide guidance for some of the major vendors...

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Monday, October 30, 2017 11:11 PM
  • Dell optiplex (9020 for example). We enable the TPM chip and if we manually enable bitlocker we need to reboot and press one of the F keys then it will encrypt. Doing it through the TS just fails. Another model is the HP G2, same type of issue. Thanks for the help!
    Monday, October 30, 2017 11:25 PM
  • The high-level steps to enable BitLocker during a TS are:

    • make sure TPM is on and activated
    • (optional) enable pre-provisioning
    • if TPM module had been used before, clear it
    • Enable BitLocker

    If you need assistance, please open a new thread, so that we can keep some resemblance of a structure here. :)

    Back to topic: again, this is the high-level approach:

    To store ownership tag in the BIOS:

    On Dell systems:

    1. Install HAPI drivers:

    hapint64.exe -i -k C-C-T-K -p "hapint64.exe" -q


    2. Set Ownership tag

    cctk.exe --propowntag="Hostname" --valsetuppwd=Password

    On HP systems:

    Note: Depending on HW generation, BIOS property name may be called differently.

    There is just one step if you are using BiosConfigUtlity:

    BiosConfigUtility64.exe /SetValue:"Ownership Tag","Hostname" /CurSetupPasswordFile:"password.bin"'

    You could wrap this into a PowerShell script and pull data from SMS TS environment (primarily OSDComputerName value).  I typically run the script inside of Windows PE at the beginning of a TS (in case TS fails the device will carry over assigned computer name for subsequent reinstalls).

    To pull data from BIOS, I would recommend using a UserExit script during the initial Gather process:

    Here is an example how to pull data from HP BIOS using a UserExit script:

    Case "HEWLETT-PACKARD", "HP"
             oLogging.CreateEntry "USEREXIT:Make = HP", LogTypeInfo ' connect to the HP WMI provider strService = "winmgmts:{impersonationlevel=impersonate}//" strComputer = "." strNamespace = "/root/HP/InstrumentedBIOS" strQuery = "select * from HP_BIOSSetting" On Error Resume Next Set objWMIService = GetObject(strService & strComputer & strNamespace) Set colItems = objWMIService.ExecQuery(strQuery,,lFlags) If Err then oLogging.CreateEntry "Error querying HP_BIOSSetting: " & Err.Description & " (" & Err.Number & ")", LogTypeError Else Counter = 1 For Each objItem In colItems If (objItem.Name = "Ownership Tag") Then If objItem.Value <> "" Then SetComputerNameAlias = objItem.Value oLogging.CreateEntry "USEREXIT:ComputerNameAlias set to " & SetComputerNameAlias, LogTypeInfo Else oLogging.CreateEntry "USEREXIT:ComputerNameAlias is empty.", LogTypeInfo

    End If End If Counter = Counter + 1 Next End If


    On Dell systems, I would go down the cctk route: read the value of the Ownership Tag, filter the result, assign the value if not empty, otherwise CustomSettings.ini evaluation will proceed and a computer name will be created based on your rules.


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".


    • Edited by Anton Romanyuk Tuesday, October 31, 2017 7:19 AM code formatting
    • Marked as answer by swindmiller Thursday, November 2, 2017 11:08 AM
    Tuesday, October 31, 2017 7:18 AM
  • EDIT: You can ignore the problem below but I am leaving the info here in case it needs to referenced. I left out the line:"ValidateComputerNameSelect = TRUE" in the VBS script. Sorry, that was a boneheaded mistake but I am still learning :)

    Having a another thought. This method (below) may not work the way I think. I assume I would have to now re-write the DeployWiz_ComputerName script as well. Settings in the CS.ini will not know what this new variable is set to because the CS runs before I set this variable, right?



    Thanks for all the help Anton! I am going to give this a try and show it to my team. Before you posted all of this they did seem to like the idea of a page they could select New Computer or Reimage to determine the ComputerName.

    I had started messing with the Deployment Toolkit Wizard Editor and kind of have it but am stuck at one step. If you would rather I can open another topic to keep this one on track.

    I basically hacked the code from a few other VBS scripts to make mine, but its really simple so far. I have a page with 2 radio buttons, Reimage and New Computer that would set a variable that I could use to pick with computer naming method I would want to use. This is the HTML code:

    <H1>Select the deployment type</H1>
    <table width=100%>
    	<tr>
    		<td>
    			<input type=radio name="ComputerNameSelect" id="CNRadio1" language=vbscript>
    		</td>
    		<td>
    			<Label class="Larger" for=CNRadio1 language=vbscript >New Computer</Label>
    		</td>
    	</tr>
    		<tr>
    		<td></td>
    		<td>
    			<p>Computer Name will be automatically generated based on the serial number</p>
    		</td>
    	</tr>
    	
    	<tr><td colspan=2>&nbsp;</td></tr>
    
    	<tr>
    		<td>
    			<input type=radio name="ComputerNameSelect" id="CNRadio2" language=vbscript>
    		</td>
    		<td>
    			<Label class="Larger" for=CNRadio2 language=vbscript >Reimage</Label>
    		</td>
    	</tr>
    	<tr>
    		<td></td>
    		<td>
    			<p>Existing Computer Name will be used</p>
    		</td>
    	</tr>
    </table>

    This is the VBS:

    Function ValidateComputerNameSelect
    	' Check Warnings
    	ParseAllWarningLabels
    	
    	If CNRadio1.checked then
    		oEnvironment.Item("CustomPCName") = "NewComputer"
    		ElseIf CNRadio2.checked then
    		oEnvironment.Item("CustomPCName") = "Reimage"
    	End If
    End Function

    I have a "Initialization" set to: InitializeComputerNameSelect

    a "Validation" set to: ValidateComputerNameSelect

    and a "condition" set to: UCase(Property("SkipComputerNameSelect"))<>"YES"

    If I test it in the Wizard of the Toolkit Editor the page shows up, I select a radio button and click Next but it never advances to the next page but I get no error. If I cancel I get the screen that shows all the variables, I do see at the bottom my CustomPCName variable and it is set correctly.

    I just do not know why the Next is not working. I am certain it is something really stupid on my part but all of this is so new to me that I just cannot figure it out.

    If you cannot help, like I said, I can post another topic but it is related to this one so figured I would try here first since you have been so helpful.

    Thanks,

    Scott





    • Edited by swindmiller Tuesday, October 31, 2017 5:06 PM
    Tuesday, October 31, 2017 4:19 PM
  • Yes, CustomSettings.ini evaluation runs before main UI comes up (notice the distinction, as I will come back to that later). You can, however, move a portion of CS into TS specific Gather step. I routinely put language pack GUIDS into a separate INI file CustomSettings_%TaskSequenceID%.ini and then add a second Gather step in the TS that points to this INI file. Since that might not work for you, you could go down a different route and alter the Welcome.xml file and run the query before CustomSettings.ini evaluation kicks in. For instance, at a customer we are using that part of the initialization process to query location code which is then used by the webservice to determine computer name, regional settings, etc during the CustomSettings.ini processing.

    Edit: +1 for figuring it out on your own.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".



    Wednesday, November 1, 2017 9:11 AM
  • Dell optiplex (9020 for example). We enable the TPM chip and if we manually enable bitlocker we need to reboot and press one of the F keys then it will encrypt. Doing it through the TS just fails. Another model is the HP G2, same type of issue. Thanks for the help!
    I image almost all Dell computers so I can help you out with BitLocker since encryption is required where I work. I can tell you how to use CCTK without having to actually install it on your systems.

    If this post is helpful please vote it as Helpful or click Mark for answer.

    Wednesday, November 1, 2017 1:55 PM
  • Dan_Vega,

    That would be great! Do you want me to start a new topic, reach out privately or post here?

    Anton,

    Thanks for the info on the Welcome.xml. After playing around with the Wizard Editor I am learning alot with how everything works. I came up with a way that will work great for us, and dropped the extra page to pick New Computer or Reimage. I made the changes on the actual Computer Name page.

    I have that VBS I mentioned earlier for capturing the existing computer name (retainPCname.vbs).

    I added this to the customsettings.ini to basically set a variable with the existing computer name and new computer name, regardless if they are used or not.

    UserExit=retainPCname.vbs
    
    OSDComputernameExisting=#GetOfflineComputername()#
    
    OSDComputernameNew=PSY-#Right("%SerialNumber%",11)#


    I added this section to the DeployWiz_ComputerName.xml file:

    <table style="width: 100%;">
    	<tr>
    			<td style="width:57px;">
    		</td>
    		<td>
    			<input type=radio name="ComputerNameSelect" id="CNRadio1" language=vbscript onclick=ValidateComputerNameSelect>
    			Reimage - Attempt to detect the computer's existing name, and use it as the new computer name.
    			<br></br>
    			<input type=radio name="ComputerNameSelect" id="CNRadio2" checked language=vbscript onclick=ValidateComputerNameSelect>
    			New Image - Use the computer's serial number to generate the computer name.
    			<br></br>
    			<br></br>
    			<br></br>
    		</td>
    	</tr>
    	</table>

    And this section to the DeployWiz_ComputerName.vbs file:

    Function ValidateComputerNameSelect
    	' Check Warnings
    	ParseAllWarningLabels
    	
    	If CNRadio1.checked then
    		OSDComputerName.Value = oEnvironment.Item("OSDComputerNameExisting")
    		ValidateComputerNameSelect = TRUE
    	ElseIf CNRadio2.checked then
    		OSDComputerName.Value = oEnvironment.Item("OSDComputerNameNew")
    		ValidateComputerNameSelect = TRUE
    	End if
    End Function

    This will allow them to go back and forth with using the radio buttons if they need to. Works great in testing but have to double check. Thanks for all your help!

    Scott




    • Marked as answer by swindmiller Thursday, November 2, 2017 11:07 AM
    Wednesday, November 1, 2017 6:14 PM
  • You can email me.

    If this post is helpful please vote it as Helpful or click Mark for answer.


    • Edited by Dan_Vega Thursday, November 2, 2017 1:10 PM
    Wednesday, November 1, 2017 6:51 PM
  • As a rule of thumb, if it works for you, then you are doing a superb job of extending the MDT functionality. This is why I consider MDT to be the best free deployment solution out there: easy to learn, highly flexible, hard to master.

    As usual, please remember to click "Mark as Answer" or "Vote" on the posts which were helpful to answering your question. This includes any reply that was posted by yourself or others. In doing so, it will benefit all community members who are facing similar issues.


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Thursday, November 2, 2017 9:02 AM
  • Anton,

    You mentioned the Bitlocker issue above a few days ago and it did not fully kick in as to why that would not work, it does now :)

    My current method works fine on a non-encrypted drive but comes up blank on an encrypted drive, I assume because I cannot read the data of a "locked" drive, right?

    Your method with storing the computername in the BIOS, that will bypass this issue since I am reading from the BIOS and not the filesystem, right? Wouldn't the name have to be stored in the BIOS before the "ReImage", otherwise I assume I would have the same problem. How do you go about doing that, during the initial image of the computer?

    Thanks,

    Scott

    Friday, November 3, 2017 5:11 PM
  • Yep. See my reply above - I posted a few examples for HP and Dell systems. It is one of the first steps in my TS to "brand" the device. This way, even if the initial installation fails, I can still grab the computer name value stored in the BIOS.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Friday, November 3, 2017 8:49 PM
  • Thanks! I get how to pull the data but when do you put the data in the bios? You would have to do it in advance, right? Otherwise there would be no way to read the computer name during the image because of the Bitlocker issue. Sorry for not getting it the first time :) Scott
    Friday, November 3, 2017 9:44 PM
  • I run the branding step before the format and partition step.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Saturday, November 4, 2017 3:01 PM