Script to Edit SCCM ConfigMgr Program Setting Under Requirement Tab

3

I have seen the people requesting for the script so that they can change This program can run only on specified client platforms option in the program properties . In a scenario we are looking to migrate all the machines to Windows 7 and all the packages already created with the requirement that they install on XP environment platform only. We can edit the program setting under requirement tab to make it possible to run on Windows 7, but there are ways to automate it. There is a script that I have seen can read a package list from a txt files and add a platform like “Windows 7”.

Script to Edit SCCM ConfigMgr Program Setting Under Requirement Tab 1

Copy the below script

  ‘ Run the query to get the package.
  Set package = connection.Get(packageQuery)
 
  ‘ Output package name and ID.
  wscript.echo “Package ID:   ” & package.PackageID
  wscript.echo “Package Name:  ” & package.Name
 
  ‘ Build a query to get the programs for the package.
  programQuery = “SELECT * FROM SMS_Program WHERE PackageID='” & existingPackageID & “‘”
 
  ‘ Run the query to get the programs.
  Set allProgramsForPackage = connection.ExecQuery(programQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)
  ‘The query returns a collection of program objects that needs to be enumerated.
  For Each program In allProgramsForPackage       
    If program.ProgramName = existingProgramName Then
      ‘Get all program object properties (in this case we specifically need some lazy properties).
       programPath = program.Put_
       Set program = connection.Get(programPath)
       ‘ Check whether RUN_ON_SPECIFIED_PLATFORMS is already set.
       checkPlatformValue = (program.ProgramFlags XOR RUN_ON_SPECIFIED_PLATFORMS)
      If checkPlatformValue = 0 Then
        ‘ RUN_ON_SPECIFIED_PLATFORMS is not set. Setting RUN_ON_SPECIFIED_PLATFORMS value.
        program.ProgramFlags = (program.ProgramFlags XOR RUN_ON_SPECIFIED_PLATFORMS)
      End If          
            
      ‘ Output the program name that is being checked for supported platforms.
      wscript.echo “Program Name: ” & program.ProgramName
     
      ‘ Create
      Set tempSupportedPlatform = connection.Get(“SMS_OS_Details”).SpawnInstance_
          
      ‘ Populate tempSupportedPlatform values. 
      tempSupportedPlatform.MaxVersion = newMaxVersion
      tempSupportedPlatform.MinVersion = newMinVersion
      tempSupportedPlatform.Name    = newName
      tempSupportedPlatform.Platform  = newPlatform
 
      ‘ Get the array of supported operating systems.
      tempSupportedPlatformsArray = program.SupportedOperatingSystems 
     
      ‘ Add the new supported platform values (object) to the temporary array.
      ‘ReDim Preserve tempSupportedPlatformsArray (Ubound(tempSupportedPlatformsArray) + 1)
      ‘Loop to search All X86 Windows XP’
      For i=0 to Ubound(tempSupportedPlatformsArray)
      If ((tempSupportedPlatformsArray(i).MinVersion = “5.10.0000.0”) AND (tempSupportedPlatformsArray(i).MaxVersion = “5.10.9999.9999”)AND (tempSupportedPlatformsArray(i).Platform = “I386”))Then
      ‘If platform is All X86 Windows XP replace by Windows XP SP2’
       Set tempSupportedPlatformsArray(i) = tempSupportedPlatform
      Else
        wscript.echo tempSupportedPlatformsArray(i).Platform
      End If
      Next
      ‘ Replace the SupportedOperatingSystems object array with the new updated array.
      program.SupportedOperatingSystems = tempSupportedPlatformsArray
      ‘ Save the program.
      program.Put_
      ‘ Output success message.
      wscript.echo “Supported Platforms Updated “
    End If   
  Next
End Sub

P.S – Test the script in LAB environment before applying it on PROCUCTION.

References –SDK SMS_OS_Details server WMI Class and Technet Thread.

 

3 COMMENTS

  1. Hi thanks for posting this. I was looking for a script to enable my programs to run on Windows 10 x64, for the ones that have Windows 7 x64 enabled already. Wanted to enable the checkbox under the Requirements tab. Would I update this section as the below?:
    tempSupportedPlatform.MaxVersion = “10.00.99999.9999”
    tempSupportedPlatform.MinVersion = “10.00.0000.0”
    tempSupportedPlatform.Name = “Win NT”
    tempSupportedPlatform.Platform = “x64”
    ‘ Get the array of supported operating systems.
    tempSupportedPlatformsArray = program.SupportedOperatingSystems

    ‘ Add the new supported platform values (object) to the temporary array.
    ‘ReDim Preserve tempSupportedPlatformsArray (Ubound(tempSupportedPlatformsArray) + 1)
    ‘Loop to search All X86 Windows XP’
    For i=0 to Ubound(tempSupportedPlatformsArray)
    If ((tempSupportedPlatformsArray(i).MinVersion = “6.10.0000.0”) AND (tempSupportedPlatformsArray(i).MaxVersion = “6.10.9999.9999”)AND (tempSupportedPlatformsArray(i).Platform = “x64”))Then

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.