How to use a custom Property in MDT for a script

Martin Wierenga 0 Reputation points
2023-06-22T18:32:53.7233333+00:00

I'm trying to deploy a application through a Powershell script that needs to have an ID attached that is corresponding with a certain group. Now I created a custom Property in my customsettings.ini/Rules like Property=ProgID, but it seems I can't figure out how to pass this on to a script for example when I create a new application and use %SCRIPTROOT%/subfolder/programsetup.exe -parameter:ProgID. I've use %ProgID%, $TSvar:ProgID, $env:ProgID but I must be missing something or my Google-fu is just bad, what do I use? TIA

Windows for business | Windows Client for IT Pros | Devices and deployment | Set up, install, or upgrade
Windows for business | Windows Server | User experience | PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. AllenLiu-MSFT 49,316 Reputation points Microsoft External Staff
    2023-06-23T02:05:01.31+00:00

    Hi, @MartinWierenga

    Thank you for posting in Microsoft Q&A forum.

    To use a custom property in MDT for a script, we may try to add the custom property to the CustomSettings.ini file and then reference it in a PowerShell script using the $tsenv variable. For example, if we added the following line to the CustomSettings.ini file:

    ProgID=1234
    

    We can reference this property in a PowerShell script using $tsenv:ProgID. For example:

    $ProgID = $tsenv:ProgID
    & "$env:SCRIPTROOT\subfolder\programsetup.exe" -parameter:$ProgID
    

    In this example, the ProgID custom property is stored in the $ProgID variable and passed as a parameter to the programsetup.exe script using the -parameter switch.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Add comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.