none
Set Custom Variable for CustomSettings.ini over WMI Query with Powershell?

    Question

  • Hi all.

    im am new here in this Portal, and i hope you can gave me useful tipps ;)

    a.) Is it possible to set a custom variable for TaskSequence / CustomSettings.ini by wmi query?

    something like this

    if (Get-WmiObject win32_computersystem where manufacturer like Lenovo ) ( set variable Model like Get-WmiObject win32_computersystemproduct from version )

    result will be ... Model before 42406AG ... Model after Thinkpad T520

    b.) How can i set custom variables for Bootstrap.ini

    tried this but it doenst work

    [Settings]
    Priority=Default
    Properties=MDTRoot, MDTServer

    [Default]
    MDTServer=SHYP01
    MDTRoot=mdttestlab
    DeployRoot=\\%MDTServer%\%MDTRoot%$

    ;Settings for all
     SkipBDDWelcome=NO

    ;Credentials for Network Access
     UserID=mslabsvc
     UserPassword=mslabsvc
     UserDomain=SHYP01

    ;Settings Language and TimeZone
      KeyboardLocale=de-DE
      InputLocale=de-DE
      UserLocale=de-DE
      UILanguage=de-DE

    Error: A connection to the deployment share (\\%MDTServer%\%MDTRoot%$) could not be made.

    I hope you have great idea's for this situations :)

    HNE

    Greetz from Frankfurt

    Saturday, October 05, 2013 9:52 PM

All replies

  • Hi Bernd,For the first question, you can use a UserExit script, there has been a well documented ModelAlias script found here that may suit your needs:

    http://deploymentbunny.com/2012/05/01/modelalias-user-exit-for-microsoft-deployment-toolkit-20102012/

    As for the second question, I am not sure what exactly you are trying to achieve? Can you clarify please?


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”

    Sunday, October 06, 2013 7:06 AM
  • For A, as already posted see:

    http://deploymentbunny.com/2012/05/01/modelalias-user-exit-for-microsoft-deployment-toolkit-20102012/

    For B:, it seems like it should work. Only thing I see strange is our use of the $.

    Is your share actually defined as mdttestlab$ ? If it is, technically your syntax should work, but why don't you just define MDTRoot as what it is?

    In other words, do this:

    MDTServer=SHYP01
    MDTRoot=mdttestlab$
    DeployRoot=\\%MDTServer%\%MDTRoot%

    Instead of this:

    MDTServer=SHYP01
    MDTRoot=mdttestlab
    DeployRoot=\\%MDTServer%\%MDTRoot%$

    I don't see any benefit to not defining the MDTRoot variable to exactly what it is. Unless you have a specific reason, it's just bad coding.

    In this example, you might remember because the variable and it's usage are right next to each other. But if they are separated by more than a few lines of code, or defined in a different script elsewhere, chances are good you won't remember "Oh, I have to not add the $ here, because the script does it later"

    Otherwise, If your share is not named mdttestlab$ , then adding a $ to the end of it in the ini file is wrong, and doesn't do anything. Creating a sharename that ends with $ hides it from browsing. Adding it when referencing it later, doesn't work.


    Sunday, October 06, 2013 2:33 PM
  • If you want to call custom properties in the same cs.ini file you need to set them in a previous section, like this:

    [Settings]
    Priority=Init, Default
    Properties=MDTRoot, MDTServer

    [Init]
    MDTServer=SHYP01
    MDTRoot=mdttestlab

    [Default]
    DeployRoot=\\%MDTServer%\%MDTRoot%$

    ;Settings for all
    SkipBDDWelcome=NO

    ;Credentials for Network Access
    UserID=mslabsvc
    UserPassword=mslabsvc
    UserDomain=SHYP01

    ;Settings Language and TimeZone
    KeyboardLocale=de-DE
    InputLocale=de-DE
    UserLocale=de-DE
    UILanguage=de-DE

    As far as your first question goes, use a userexit, or the built-in Model variable.

    / Johan


    Regards / Johan Arwidmark Twitter: @jarwidmark Blog: http://www.deploymentresearch.com FB: www.facebook.com/deploymentresearch

    Sunday, October 13, 2013 10:31 PM
    Moderator
  • Hi @all,

    sorry for late reply.

    Question a) should be the result something like this

    set "mdtHWmodel="

    if manufacturer like LENOVO ( set "mdtHWmodel=get-wmiobject win32_computersystemproduct | select-object version" ) else ( set "mdtHWmodel=get-wmiobject win32_computersystem | select-object Model" )

    if exist "%mdtHWmodel" in .\DriverPackages\ than take this as OS Driver Package

    I am not sure how to make this, but with this solutions it will be possible in 2-3 steps to manage a lot HWModels from different Manufacturer.

    With the Script from deploymentbunny i tried but it doenst works for this request.

    Question b) i will test the solution from Johan, i think this shoud work. I will reply about.

    HND Greetz from Frankfurt :)

    Monday, October 14, 2013 11:04 AM
  • The modelaliasexit.vbs userexit script you can download from the deployment guys web page does exactly that.

    Calls different methods depending on Make/Model

    / Johan


    Regards / Johan Arwidmark Twitter: @jarwidmark Blog: http://www.deploymentresearch.com FB: www.facebook.com/deploymentresearch

    Monday, October 14, 2013 9:59 PM
    Moderator