Unable to Assign MSI with MST to GPO Computer Configuration Using PowerShell

dipeeka pise 0 Reputation points
2025-02-04T03:06:47.9733333+00:00
  • Is there a PowerShell method to properly assign an MST along with an MSI to GPO Computer Configuration?
  • Does SoftwareInstallation.CreatePackage() support MST assignments via PowerShell?
  • Is there an alternative way (like modifying registry or using COM objects) to force MST association?

Any guidance or working PowerShell scripts would be highly appreciated! 🚀

This question is related to the following Learning Module

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,802 questions
Windows Training
Windows Training
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Training: Instruction to develop new skills.
32 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pradeep M 5,760 Reputation points Microsoft Vendor
    2025-02-06T05:30:49.2166667+00:00

    Hi dipeeka pise

    Thank you for reaching out to Microsoft Q & A forum. 

    Yes, you can assign an MST (Transform) file along with an MSI in Group Policy Software Installation, but the SoftwareInstallation.CreatePackage() method in PowerShell does not directly support MST assignments. However, you can modify the package properties after creation to include the MST file  

    PowerShell Method: 

    You can use the IGroupPolicyObject COM interface to configure the MST file alongside the MSI. Below is a step-by-step approach: 

    1.Create the GPO and Assign the MSI 

    2.Modify the GPO to Include the MST File 

    Here’s a PowerShell script to achieve this: 

    # Load the Group Policy Management COM Object
    $gpm = New-Object -ComObject 'GPMgmt.GPM'
    # Open the Group Policy Object (GPO)
    $gpo = $gpm.GetGPO("{GPO-GUID-HERE}")  # Replace with actual GPO GUID or retrieve by name
    # Get the Software Installation Policy
    $si = $gpo.GetSoftwareInstallation("Computer")  # Target Computer Configuration
    # Define MSI and MST Paths
    $msiPath = "\\server\share\software.msi"
    $mstPath = "\\server\share\transform.mst"
    # Assign the MSI Package
    $package = $si.CreatePackage($msiPath, 1)  # 1 = Assigned Installation
    # Modify the Package Properties to Include the MST File
    $package.Modify(2, "TRANSFORMS=$mstPath")  # 2 = Modify existing package
    # Save and Apply Changes
    $gpo.Save()
    
    

    Alternative Methods: 

    If PowerShell does not fully support this, consider these options: 

    1.Using Group Policy Management Console (GPMC) Manually 

    Open Group Policy Management Editor 

    Navigate to Computer Configuration > Software Settings > Software Installation 

    Create a new software installation package and assign the MSI 

    Right-click the package, go to Properties > Modifications, and add the MST file 

    2.Using a Startup Script 

    If the MST file needs to be applied post-installation, use a batch or PowerShell script in Computer Configuration > Windows Settings > Scripts (Startup/Shutdown) to apply the MST file after MSI installation. 

    Please feel free to contact us if you have any additional questions.     

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.  

    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.