none
MDT OSDComputerName to pull First word of Make as the computer name RRS feed

  • Question

  • This is my current syntax to getting the OSDComputerName

    :Set ComputerName
    OSDComputerName=#Left("%Make%",9)#-#right("%SerialNumber%",4)#

    This however does not properly name my computer if it comes from different manufacturers.

    eg. AsusTek Computer Inc, Dell, Lenovo, Microsoft Corporation

    With my current syntax, it will grab the first 9 character from the left, so if its an asus PC being deployed, it'll show as
    AsusTek C-SerialNumber.

    Is there any way to make it so that as soon as it finds the first Space, then the previous characters of the %Make% are used for OSDComputerName.

    Sunday, February 24, 2019 3:52 AM

All replies

  • I would use a split function using the space as the split then you can reference the first item in the array.

    https://www.w3schools.com/asp/func_split.asp

    Monday, February 25, 2019 2:18 PM
  • There are a plethora of solution for this problem, here is a very lazy one that you can use in your customsettings.ini:

    [Settings]
    Priority=Make, Default
    Properties=PrefixName
    
    [AsusTek Computer Inc]
    PrefixName=AsusTek
    
    [Dell Inc.]
    PrefixName=Dell
    
    [Microsoft Corporation]
    PrefixName=Microsoft
    
    [Default]
    OSDComputerName=%PrefixName%-#right("%SerialNumber%",4)#
    Use the PrefixName property to set the 'make' part exacty the way you want.


    Monday, February 25, 2019 2:19 PM
  • This is actually very lazy perhaps quite labour intensive lol

    actually not so much as there are only so many manufacturers but still.

    This is a great alternative tho. I'll use if all fails.

    Thanks!

    Thursday, March 21, 2019 12:42 AM
  • Thanks ill try this split function out and see how it goes.
    Thursday, March 21, 2019 12:42 AM
  • Hi,

    Did you get this to work using split?

    I'm trying to get the last part of a string. i.e "Model 1234", i would only need "1234" or if the model was "12345" i would need "12345" using the space as the separator.

    Thanks in advance  

    Wednesday, November 13, 2019 11:56 AM
  • The below works, if the model is something like PowerEdge 1234

    OSDComputerName=PREFIX-#Split("%Model%", " ")(1)#-

    The (1) can be changed depending of the indexing\element to be returned. If you were to set it to (0), PowerEdge would be returned.

    To test, you create a VBS script file of

    vSplit = Split("PowerEdge 1234", " ")(1)
    WScript.Echo vSplit


    • Proposed as answer by biziee Thursday, November 14, 2019 11:43 AM
    Thursday, November 14, 2019 11:43 AM