diff --git a/intune/configmgr/develop/apps/deployment-type-extension-versioning.md b/intune/configmgr/develop/apps/deployment-type-extension-versioning.md index 0c100ee067..686ce91b3a 100644 --- a/intune/configmgr/develop/apps/deployment-type-extension-versioning.md +++ b/intune/configmgr/develop/apps/deployment-type-extension-versioning.md @@ -6,16 +6,21 @@ ms.subservice: sdk ms.topic: install-set-up-deploy ms.collection: tier3 --- + # Deployment Type Extension Versioning + Configuration Manager supports in-place versioning for minor upgrades and out-of-place versioning for major upgrades. ## Versioning ### Minor Revisions - Configuration Manager supports in-place versioning for minor upgrades that are backwards compatible. For in-place versioning, increment the version number. + +Configuration Manager supports in-place versioning for minor upgrades that are backwards compatible. For in-place versioning, increment the version number. ### Major Revisions - Configuration Manager supports out-of-place versioning for major upgrades that aren't backwards compatible. For out-of-place versioning, it's necessary to create a new extension and technology ID. + +Configuration Manager supports out-of-place versioning for major upgrades that aren't backwards compatible. For out-of-place versioning, it's necessary to create a new extension and technology ID. ## See Also - [Configuration Manager Reference](../../develop/reference/configuration-manager-reference.md) + +[Configuration Manager Reference](../../develop/reference/configuration-manager-reference.md) diff --git a/intune/configmgr/develop/apps/extending-application-management-overview.md b/intune/configmgr/develop/apps/extending-application-management-overview.md index adee01fbb1..6369d7491b 100644 --- a/intune/configmgr/develop/apps/extending-application-management-overview.md +++ b/intune/configmgr/develop/apps/extending-application-management-overview.md @@ -6,19 +6,21 @@ ms.subservice: sdk ms.topic: article ms.collection: tier3 --- + # Extending Application Management Overview + By default, Application Management supports creating numerous deployment types such as Windows Installer, Script Installer, Microsoft Application Virtualization, Nokia SIS files and Windows Mobile Cabinet file deployment technologies. Partners that must continue to use a specific deployment technology not natively supported by Configuration Manager, can extend the Application Management model to support a custom deployment type. - In Application Management, the application object is the high-level object that Configuration Manager Administrators will create, deploy and monitor. The deployment type object represents the technology that will be detected, installed and uninstalled on the end-user systems. The Application Management model can be extended by creating an instance of deployment type with a custom deployment technology. +In Application Management, the application object is the high-level object that Configuration Manager Administrators will create, deploy and monitor. The deployment type object represents the technology that will be detected, installed and uninstalled on the end-user systems. The Application Management model can be extended by creating an instance of deployment type with a custom deployment technology. - The deployment type object is composed of multiple objects: deployment technology, hosting technology, installer technology, content importer and the installer. The installer object is a key extension point, as it provides the properties for a technology, as well as the logic for detection, installation and uninstallation of the technology on the client system. +The deployment type object is composed of multiple objects: deployment technology, hosting technology, installer technology, content importer and the installer. The installer object is a key extension point, as it provides the properties for a technology, as well as the logic for detection, installation and uninstallation of the technology on the client system. - Extending the application model requires extending the Configuration Manager consoles and Configuration Manager clients that will leverage the custom deployment type. On the server, the extension is accomplished through creating and registering a custom deployment technology assembly and by extending Configuration Manager console (adding custom property sheets and wizards). The client extension is accomplished through extending WMI and adding a custom handler (a public COM class and methods). It should be noted that the client extension closely maps to the installer object, defined as part of the deployment type. The properties and methods defined in the installer object map directly to the property values are stored in WMI and the public COM methods defined in the custom handler. +Extending the application model requires extending the Configuration Manager consoles and Configuration Manager clients that will leverage the custom deployment type. On the server, the extension is accomplished through creating and registering a custom deployment technology assembly and by extending Configuration Manager console (adding custom property sheets and wizards). The client extension is accomplished through extending WMI and adding a custom handler (a public COM class and methods). It should be noted that the client extension closely maps to the installer object, defined as part of the deployment type. The properties and methods defined in the installer object map directly to the property values are stored in WMI and the public COM methods defined in the custom handler. - In conceptualizing a custom deployment type, it might be useful to consider the in-product handling of Windows Installer files (*.msi). +In conceptualizing a custom deployment type, it might be useful to consider the in-product handling of Windows Installer files (\*.msi). > [!TIP] -> A complete sample project implementing a custom deployment type for Remote Desktop Protocol (*.rdp) files is provided separately for reference. The discussion throughout the Extending Application Management section leverages the Remote Desktop Protocol sample project for examples and illustration. +> A complete sample project implementing a custom deployment type for Remote Desktop Protocol (\*.rdp) files is provided separately for reference. The discussion throughout the Extending Application Management section leverages the Remote Desktop Protocol sample project for examples and illustration. ## Overview @@ -26,8 +28,7 @@ By default, Application Management supports creating numerous deployment types s 1. Create a Custom SDK Assembly - The custom SDK assembly contains an interface implementation of both the Hosting Technology and Installer Technology. The AssemblySuffix should correspond to whatever is specified for AssemblySuffix attribute in the DeploymentTechnology.xml file, for example Microsoft.ConfigurationManagement.ApplicationManagement.\<*AssemblySuffix*>.dll. - + The custom SDK assembly contains an interface implementation of both the Hosting Technology and Installer Technology. The AssemblySuffix should correspond to whatever is specified for AssemblySuffix attribute in the DeploymentTechnology.xml file, for example Microsoft.ConfigurationManagement.ApplicationManagement.\<_AssemblySuffix_>.dll. 1. Deployment Technology - The DeploymentTechnology class is the object that is registered with the Configuration Manager Application Model SDK. When implementing a new deployment technology you must implement a class that derives from this class. The new class instance will define the deployment technology used to deploy a specific application to devices. 2. Hosting Technology - The HostingTechnology class is used to define run time interaction and configuration for technologies. @@ -36,14 +37,13 @@ By default, Application Management supports creating numerous deployment types s 4. Installer – The Installer class is used to define properties and methods used on the client to actually detect, install and uninstall the application. - 5. Content Importer - The ContentImporter class is used to allow custom technologies to be able to read a specific content file and create the corresponding DeploymentType object using information obtained from the content file. For example, the Windows Installer content importer reads Windows Installer files (*.msi) and is able to populate Title, Description properties of the Installer DeploymentType object and create the Detect, Install and Uninstall actions for the Installer. + 5. Content Importer - The ContentImporter class is used to allow custom technologies to be able to read a specific content file and create the corresponding DeploymentType object using information obtained from the content file. For example, the Windows Installer content importer reads Windows Installer files (\*.msi) and is able to populate Title, Description properties of the Installer DeploymentType object and create the Detect, Install and Uninstall actions for the Installer. 6. Resources – To support the Installer, a custom XML schema should be included as part of the assembly. The schema file (XSD) file must be included as a resource in the assembly. 2. Create the Registration XML Files - As part of defining a custom application management deployment technology, create three registration files/digests. These registration files/digests are used to register the Deployment Technology with Configuration Manager. - + As part of defining a custom application management deployment technology, create three registration files/digests. These registration files/digests are used to register the Deployment Technology with Configuration Manager. 1. DeploymentTechnology.xml - Digest of the Deployment Technology. 2. HostingTechnology.xml - Digest of the Hosting Technology. @@ -52,58 +52,56 @@ By default, Application Management supports creating numerous deployment types s 3. Create the UI Extension - To extend the Configuration Manager console, create a UX assembly, custom property sheets and wizards. + To extend the Configuration Manager console, create a UX assembly, custom property sheets and wizards. - The assembly should correspond to following naming convention: AdminUI.DeploymentType.\<*AssemblySuffix*>.dll. + The assembly should correspond to following naming convention: AdminUI.DeploymentType.\<_AssemblySuffix_>.dll. + 1. AdminUI.DeploymentType.\<_AssemblySuffix_>.dll - 1. AdminUI.DeploymentType.\<*AssemblySuffix*>.dll + Required – Contains UX implementation, which is then bound to the Configuration Manager console using the following XML files: - Required – Contains UX implementation, which is then bound to the Configuration Manager console using the following XML files: + 2. CreateApp\_\<_TechnologyId_>.xml - 2. CreateApp_\<*TechnologyId*>.xml + Required – Extension XML for the Create Application Wizard. - Required – Extension XML for the Create Application Wizard. + 3. CreateDeploymentWizard\_\<_TechnologyId_>.xml - 3. CreateDeploymentWizard_\<*TechnologyId*>.xml + Required - Extension XML for the Deployment Type Wizard. - Required - Extension XML for the Deployment Type Wizard. + 4. \<_TechnologyId_>DeploymentTypePropertySheet.xml - 4. \<*TechnologyId*>DeploymentTypePropertySheet.xml - - Required - Standard Property Page XML for the Deployment Type property page. + Required - Standard Property Page XML for the Deployment Type property page. ### Client - The client extension is accomplished through extending WMI and adding a custom handler (public COM class and methods). It should be noted that the client extension closely maps to the Installer object, defined as part of the DeploymentType. Property values are stored in WMI and the public COM methods map to detection, installation and uninstallation. + +The client extension is accomplished through extending WMI and adding a custom handler (public COM class and methods). It should be noted that the client extension closely maps to the Installer object, defined as part of the DeploymentType. Property values are stored in WMI and the public COM methods map to detection, installation and uninstallation. 1. Create an AppSynclet MOF File - To define a custom synclet MOF file, create an instance of the CCM_AppHandlers class. The new class instance will identify the custom client-side handler. Additionally, create instances of the CCM_HandlerSynclet class which will store install, uninstall and detect property values which can be used by the corresponding client-side handler methods. + To define a custom synclet MOF file, create an instance of the CCM_AppHandlers class. The new class instance will identify the custom client-side handler. Additionally, create instances of the CCM_HandlerSynclet class which will store install, uninstall and detect property values which can be used by the corresponding client-side handler methods. 2. Create a Client-side Handler - The custom client-side handler needs to implement a public COM interface and methods (InstallApp, UninstallApp and DiscoveryApp). The methods will be called by the Configuration Manager client framework. However, the actual functionality of the methods is defined by the client-side handler developer. + The custom client-side handler needs to implement a public COM interface and methods (InstallApp, UninstallApp and DiscoveryApp). The methods will be called by the Configuration Manager client framework. However, the actual functionality of the methods is defined by the client-side handler developer. ### Installation -1. How to Create the Configuration Manager Deployment Type Extension File (*.cmdtx) - +1. How to Create the Configuration Manager Deployment Type Extension File (\*.cmdtx) 1. Create an empty directory to stage its contents 2. Create and copy the following files into this directory: - 1. DeploymentTechnology.xml - A digest of the Deployment Technology 2. HostingTechnology.xml - A digest of the Hosting Technology 3. InstallerTechnology.xml - A digest of the Installer Technology - 4. The custom SDK Assembly (Microsoft.ConfigurationManagement.ApplicationManagement.\<*AssemblySuffix*>.dll) - Contains interface implementation of both the Hosting Technology and Installer Technology Note: the AssemblySuffix should correspond to whatever is specified for AssemblySuffix attribute in the DeploymentTechnology.xml file. + 4. The custom SDK Assembly (Microsoft.ConfigurationManagement.ApplicationManagement.\<_AssemblySuffix_>.dll) - Contains interface implementation of both the Hosting Technology and Installer Technology Note: the AssemblySuffix should correspond to whatever is specified for AssemblySuffix attribute in the DeploymentTechnology.xml file. 5. HostingApplication.zip - Optional. Importable application that represents the Hosting Application, which includes content (if any). This should be created using the Export feature on the Applications node, in the Configuration Manager console. 6. HandlerApplication.zip - Optional. Importable application that represents the Handler Application for the client, which includes content (if any). This should be created using the Export feature on the Applications node, in the Configuration Manager console. - 3. Use the method DeploymentTypeExtender.CreateExtension, which is located in Microsoft.ConfigurationManagement.ApplicationManagement namespace, to create the Deployment Type Extension (*.cmdtx) file based on the content in the staging directory. + 3. Use the method DeploymentTypeExtender.CreateExtension, which is located in Microsoft.ConfigurationManagement.ApplicationManagement namespace, to create the Deployment Type Extension (\*.cmdtx) file based on the content in the staging directory. ``` // Summarizes progress from CreateExtension method to a log file or the console. @@ -123,31 +121,29 @@ By default, Application Management supports creating numerous deployment types s } ``` -2. How to Create the Windows Installer File (*.msi) - - After the *.cmdtx is created, create a Windows Installer file (\*.msi) which contains the \*.cmdtx file and UX files. The Installer will be responsible for installing the UX files in the correct locations. +2. How to Create the Windows Installer File (\*.msi) + After the \*.cmdtx is created, create a Windows Installer file (\*.msi) which contains the \*.cmdtx file and UX files. The Installer will be responsible for installing the UX files in the correct locations. 1. Install the UX files in the correct locations. Basically, this will involve including the following files (with respect to Deployment Type Extensions): - 1. AdminUI.DeploymentType.\.dll - Required – Contains UX implementation, which is then bound to the Configuration Manager console using the following XML files: + Required – Contains UX implementation, which is then bound to the Configuration Manager console using the following XML files: - 2. CreateApp_\<*TechnologyId*>.xml + 2. CreateApp\_\<_TechnologyId_>.xml - Required – Extension XML for the Create Application Wizard. + Required – Extension XML for the Create Application Wizard. - 3. CreateDeploymentWizard_\<*TechnologyId*>.xml + 3. CreateDeploymentWizard\_\<_TechnologyId_>.xml - Required - Extension XML for the Deployment Type Wizard. + Required - Extension XML for the Deployment Type Wizard. - 4. \<*TechnologyId*>DeploymentTypePropertySheet.xml + 4. \<_TechnologyId_>DeploymentTypePropertySheet.xml - Required - Standard Property Page XML for the Deployment Type property page. + Required - Standard Property Page XML for the Deployment Type property page. - 2. Register the *.cmdtx + 2. Register the \*.cmdtx - The Windows Installer file (*.msi) should contain code/script to invoke the DeploymentTypeExtender.Extend method, which is located in the Microsoft.ConfigurationManagement.ApplicationManagement namespace. This will then register the extension files for a given site server computer. For a Configuration Manager administrator console computer, this will initialize the cache for that user. + The Windows Installer file (\*.msi) should contain code/script to invoke the DeploymentTypeExtender.Extend method, which is located in the Microsoft.ConfigurationManagement.ApplicationManagement namespace. This will then register the extension files for a given site server computer. For a Configuration Manager administrator console computer, this will initialize the cache for that user. ``` using DCM = Microsoft.ConfigurationManagement.AdminConsole.DesiredConfigurationManagement; @@ -158,40 +154,43 @@ By default, Application Management supports creating numerous deployment types s ``` ## Namespaces - Microsoft.ConfigurationManagement.AdminConsole - Microsoft.ConfigurationManagement.AdminConsole.AppManFoundation +Microsoft.ConfigurationManagement.AdminConsole - Microsoft.ConfigurationManagement.AdminConsole.CreateDT +Microsoft.ConfigurationManagement.AdminConsole.AppManFoundation - Microsoft.ConfigurationManagement.AdminConsole.DesiredConfigurationManagement +Microsoft.ConfigurationManagement.AdminConsole.CreateDT - Microsoft.ConfigurationManagement.ApplicationManagement +Microsoft.ConfigurationManagement.AdminConsole.DesiredConfigurationManagement - Microsoft.ConfigurationManagement.ApplicationManagement.Serialization +Microsoft.ConfigurationManagement.ApplicationManagement - Microsoft.ConfigurationManagement.ManagementProvider +Microsoft.ConfigurationManagement.ApplicationManagement.Serialization - Microsoft.ConfigurationManagement.ManagementProvider.ConnectionManagerBase +Microsoft.ConfigurationManagement.ManagementProvider - Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine +Microsoft.ConfigurationManagement.ManagementProvider.ConnectionManagerBase + +Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine ## Assemblies - AdminUI.AppManFoundation - AdminUI.CreateDT +AdminUI.AppManFoundation + +AdminUI.CreateDT - AdminUI.DcmObjectWrapper.dll +AdminUI.DcmObjectWrapper.dll - AdminUI.WqlQueryEngine.dll +AdminUI.WqlQueryEngine.dll - Microsoft.ConfigurationManagement.exe +Microsoft.ConfigurationManagement.exe - Microsoft.ConfigurationManagement.ApplicationManagement.dll +Microsoft.ConfigurationManagement.ApplicationManagement.dll - Microsoft.ConfigurationManagement.ApplicationManagement.Extender.dll +Microsoft.ConfigurationManagement.ApplicationManagement.Extender.dll - Microsoft.ConfigurationManagement.ManagementProvider.dll +Microsoft.ConfigurationManagement.ManagementProvider.dll ## See Also - [Configuration Manager Reference](../../develop/reference/configuration-manager-reference.md) + +[Configuration Manager Reference](../../develop/reference/configuration-manager-reference.md) diff --git a/intune/configmgr/develop/apps/how-to-configure-automatic-software-metering-rule-generation.md b/intune/configmgr/develop/apps/how-to-configure-automatic-software-metering-rule-generation.md index 26fe83c259..858dbc9a59 100644 --- a/intune/configmgr/develop/apps/how-to-configure-automatic-software-metering-rule-generation.md +++ b/intune/configmgr/develop/apps/how-to-configure-automatic-software-metering-rule-generation.md @@ -6,11 +6,13 @@ ms.subservice: sdk ms.topic: how-to ms.collection: tier3 --- + # How to Configure Automatic Software Metering Rule Generation + You configure Automatic Software Metering Rule Generation settings, in Configuration Manager, by modifying the site control file. > [!IMPORTANT] -> This setting is shared across the whole hierarchy, and only can be configured on the CAS or a standalone primary site. +> This setting is shared across the whole hierarchy, and only can be configured on the CAS or a standalone primary site. ### To configure automatic software metering rule generation @@ -23,9 +25,88 @@ You configure Automatic Software Metering Rule Generation settings, in Configura 4. Commit the property changes to the site control file. ## Example - The following example method configures various Software Metering Rule Generation settings by using the [SMS_SCI_ClientComp](../../develop/reference/core/servers/configure/sms_sci_clientcomp-server-wmi-class.md) class to connect to the site control file and change properties. - For information about calling the sample code, see [Calling Configuration Manager Code Snippets](../../develop/core/understand/calling-code-snippets.md). +The following example method configures various Software Metering Rule Generation settings by using the [SMS_SCI_ClientComp](../../develop/reference/core/servers/configure/sms_sci_clientcomp-server-wmi-class.md) class to connect to the site control file and change properties. + +For information about calling the sample code, see [Calling Configuration Manager Code Snippets](../../develop/core/understand/calling-code-snippets.md). + +### PowerShell + +```powershell + +function Set-AutoSoftwareMeteringRuleGeneration { + param( + [Parameter(Mandatory=$true)] + [string]$SiteCode, + + [Parameter(Mandatory=$true)] + [string]$EnableAutoCreateDisabledRule, + + [Parameter(Mandatory=$true)] + [string]$NewAutoCreatePercentage, + + [Parameter(Mandatory=$true)] + [string]$NewAutoCreateThreshold, + + [string]$ProviderMachineName = $env:COMPUTERNAME + ) + + # Connect to the SMS Provider + $namespace = "root\sms\site_$SiteCode" + $conn = Get-WmiObject -Namespace $namespace -Class SMS_SiteControlFile -ComputerName $ProviderMachineName + + # Refresh site control file + $conn.psbase.InvokeMethod("Refresh", $null) + + # Query the Software Metering Agent component + $query = "SELECT * FROM SMS_SCI_ClientComp WHERE ClientComponentName='Software Metering Agent' AND SiteCode='$SiteCode'" + $components = Get-WmiObject -Namespace $namespace -Query $query -ComputerName $ProviderMachineName + + foreach ($comp in $components) { + foreach ($prop in $comp.Props) { + switch ($prop.PropertyName) { + + "Auto Create Disabled Rule" { + Write-Host "" + Write-Host $prop.PropertyName + Write-Host "Current value: $($prop.Value)" + + $prop.Value = $EnableAutoCreateDisabledRule + Write-Host "New value : $EnableAutoCreateDisabledRule" + } + + "Auto Create Percentage" { + Write-Host "" + Write-Host $prop.PropertyName + Write-Host "Current value: $($prop.Value)" + + $prop.Value = $NewAutoCreatePercentage + Write-Host "New value : $NewAutoCreatePercentage" + } + + "Auto Create Threshold" { + Write-Host "" + Write-Host $prop.PropertyName + Write-Host "Current value: $($prop.Value)" + + $prop.Value = $NewAutoCreateThreshold + Write-Host "New value : $NewAutoCreateThreshold" + } + } + } + + # Update the component in the local SCF copy + $comp.Put() | Out-Null + } + + # Commit the updated SCF to the site + $commitParams = $conn.psbase.GetMethodParameters("CommitSCF") + $commitParams.SiteCode = $SiteCode + $conn.psbase.InvokeMethod("CommitSCF", $commitParams, $null) +} +``` + +### Visual Basic Script ```vbs @@ -101,6 +182,8 @@ End Sub ``` +### C# + ```c# public void ConfigureAutomaticSWMRuleGeneration(WqlConnectionManager connection, @@ -174,7 +257,7 @@ public void ConfigureAutomaticSWMRuleGeneration(WqlConnectionManager connection, ``` - The example method has the following parameters: +The example method has the following parameters: | Parameter | Type | Description | | --------- | ---- | ----------- | @@ -186,33 +269,39 @@ public void ConfigureAutomaticSWMRuleGeneration(WqlConnectionManager connection, |`newAutoCreateThreshold`|- Managed: `String`
- VBScript: `String`|Sets the auto creation threshold.| ## Compiling the Code - This C# example requires: + +This C# example requires: ### Namespaces - System - System.Collections.Generic +System + +System.Collections.Generic - System.Text +System.Text - Microsoft.ConfigurationManagement.ManagementProvider +Microsoft.ConfigurationManagement.ManagementProvider - Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine +Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine ### Assembly - adminui.wqlqueryengine - microsoft.configurationmanagement.managementprovider +adminui.wqlqueryengine + +microsoft.configurationmanagement.managementprovider ## Robust Programming - For more information about error handling, see [About Configuration Manager Errors](../../develop/core/understand/about-configuration-manager-errors.md). + +For more information about error handling, see [About Configuration Manager Errors](../../develop/core/understand/about-configuration-manager-errors.md). ## .NET Framework Security - For more information about securing Configuration Manager applications, see [Configuration Manager role-based administration](../../develop/core/servers/configure/role-based-administration.md). + +For more information about securing Configuration Manager applications, see [Configuration Manager role-based administration](../../develop/core/servers/configure/role-based-administration.md). ## See Also - [Configuration Manager Software Development Kit](../../develop/core/misc/system-center-configuration-manager-sdk.md) - [About the Configuration Manager Site Control File](../../develop/core/understand/about-the-configuration-manager-site-control-file.md) - [How to Read and Write to the Configuration Manager Site Control File by Using Managed Code](../../develop/core/understand/how-to-read-and-write-to-the-site-control-file-by-using-managed-code.md) - [How to Read and Write to the Configuration Manager Site Control File by Using WMI](../../develop/core/understand/how-to-read-and-write-to-the-site-control-file-by-using-wmi.md) - [SMS_SCI_Component Server WMI Class](../../develop/reference/core/servers/configure/sms_sci_component-server-wmi-class.md) + +[Configuration Manager Software Development Kit](../../develop/core/misc/system-center-configuration-manager-sdk.md) +[About the Configuration Manager Site Control File](../../develop/core/understand/about-the-configuration-manager-site-control-file.md) +[How to Read and Write to the Configuration Manager Site Control File by Using Managed Code](../../develop/core/understand/how-to-read-and-write-to-the-site-control-file-by-using-managed-code.md) +[How to Read and Write to the Configuration Manager Site Control File by Using WMI](../../develop/core/understand/how-to-read-and-write-to-the-site-control-file-by-using-wmi.md) +[SMS_SCI_Component Server WMI Class](../../develop/reference/core/servers/configure/sms_sci_component-server-wmi-class.md) diff --git a/intune/configmgr/develop/apps/how-to-create-a-software-metering-rule.md b/intune/configmgr/develop/apps/how-to-create-a-software-metering-rule.md index 96d1f48002..9c74ce3fe7 100644 --- a/intune/configmgr/develop/apps/how-to-create-a-software-metering-rule.md +++ b/intune/configmgr/develop/apps/how-to-create-a-software-metering-rule.md @@ -6,7 +6,9 @@ ms.topic: how-to ms.collection: tier3 description: You can create a software metering rule in Configuration Manager by creating an instance of the SMS_MeteredProductRule class and populating the properties. --- + # How to Create a Software Metering Rule + You create a software metering rule, in Configuration Manager, by creating an instance of the `SMS_MeteredProductRule` class and populating the properties. ### To create software metering rule @@ -20,12 +22,67 @@ You create a software metering rule, in Configuration Manager, by creating an in 4. Save the new software metering rule and properties. ## Example - The following example method shows how to create a software metering rule by creating an instance of the `SMS_MeteredProductRule` class and populating the properties. - For information about calling the sample code, see [Calling Configuration Manager Code Snippets](../../develop/core/understand/calling-code-snippets.md). +The following example method shows how to create a software metering rule by creating an instance of the `SMS_MeteredProductRule` class and populating the properties. -```vb +For information about calling the sample code, see [Calling Configuration Manager Code Snippets](../../develop/core/understand/calling-code-snippets.md). + +### PowerShell + +```powershell +function New-CMSWMRRule { + param( + [Parameter(Mandatory=$true)] + [string]$ProductName, + + [Parameter(Mandatory=$true)] + [string]$FileName, + + [Parameter(Mandatory=$true)] + [string]$OriginalFileName, + + [Parameter(Mandatory=$true)] + [string]$FileVersion, + + [Parameter(Mandatory=$true)] + [int]$LanguageID, + + [Parameter(Mandatory=$true)] + [string]$SiteCode, + + [Parameter(Mandatory=$true)] + [bool]$ApplyToChildSites, + + [string]$ProviderMachineName = $env:COMPUTERNAME + ) + + $namespace = "root\sms\site_$SiteCode" + + # Create a new instance of SMS_MeteredProductRule + $ruleClass = [WMIClass]"\\$ProviderMachineName\$namespace:SMS_MeteredProductRule" + $newRule = $ruleClass.CreateInstance() + + # Populate properties + $newRule.ProductName = $ProductName + $newRule.FileName = $FileName + $newRule.OriginalFileName = $OriginalFileName + $newRule.FileVersion = $FileVersion + $newRule.LanguageID = $LanguageID + $newRule.SiteCode = $SiteCode + $newRule.ApplyToChildSites = $ApplyToChildSites + # Save the rule + $result = $newRule.Put() + + Write-Host "" + Write-Host "Created new SWM Rule: $ProductName" + Write-Host "WMI Path: $($result.Path)" +} +``` + +### VBScript + +```vb Sub CreateSWMRule(connection, _ newProductName, _ newFileName, _ @@ -56,8 +113,9 @@ Sub CreateSWMRule(connection, _ End Sub ``` -```c# +### C# +```c# public void CreateSWMRule(WqlConnectionManager connection, string newProductName, string newFileName, @@ -94,47 +152,52 @@ public void CreateSWMRule(WqlConnectionManager connection, throw; } } - ``` - The example method has the following parameters: +The example method has the following parameters: -|Parameter|Type|Description| -|----|----|----| -|`connection`|- Managed: `WqlConnectionManager`
- VBScript: `SWbemServices`|A valid connection to the SMS Provider.| -|`newProductName`|- Managed: `String`
- VBScript: `String`|The new product name.| -|`newFileName`|- Managed: `String`
- VBScript: `String`|The new file name.| -|`newOriginalFileName`|- Managed: `String`
- VBScript: `String`|The new original file name.| -|`newFileVersion`|- Managed: `String`
- VBScript: `String`|The new file version.| -|`newLanguageID`|- Managed: `Integer`
- VBScript: `Integer`|The new language ID.| -|`newSiteCode`|- Managed: `String`
- VBScript: `String`|The new site code.| -|`newApplyToChildSites`|- Managed: `Boolean`
- VBScript: `Boolean`|Determines whether the rule will apply to child sites.| +| Parameter | Type | Description | +| ---------------------- | ------------------------------------------------------------------ | ------------------------------------------------------ | +| `connection` | - Managed: `WqlConnectionManager`
- VBScript: `SWbemServices` | A valid connection to the SMS Provider. | +| `newProductName` | - Managed: `String`
- VBScript: `String` | The new product name. | +| `newFileName` | - Managed: `String`
- VBScript: `String` | The new file name. | +| `newOriginalFileName` | - Managed: `String`
- VBScript: `String` | The new original file name. | +| `newFileVersion` | - Managed: `String`
- VBScript: `String` | The new file version. | +| `newLanguageID` | - Managed: `Integer`
- VBScript: `Integer` | The new language ID. | +| `newSiteCode` | - Managed: `String`
- VBScript: `String` | The new site code. | +| `newApplyToChildSites` | - Managed: `Boolean`
- VBScript: `Boolean` | Determines whether the rule will apply to child sites. | ## Compiling the Code - This C# example requires: + +This C# example requires: ### Namespaces - System - System.Collections.Generic +System - System.Text +System.Collections.Generic - Microsoft.ConfigurationManagement.ManagementProvider +System.Text - Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine +Microsoft.ConfigurationManagement.ManagementProvider + +Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine ### Assembly - adminui.wqlqueryengine - microsoft.configurationmanagement.managementprovider +adminui.wqlqueryengine + +microsoft.configurationmanagement.managementprovider ## Robust Programming - For more information about error handling, see [About Configuration Manager Errors](../../develop/core/understand/about-configuration-manager-errors.md). + +For more information about error handling, see [About Configuration Manager Errors](../../develop/core/understand/about-configuration-manager-errors.md). ## .NET Framework Security - For more information about securing Configuration Manager applications, see [Configuration Manager role-based administration](../../develop/core/servers/configure/role-based-administration.md). + +For more information about securing Configuration Manager applications, see [Configuration Manager role-based administration](../../develop/core/servers/configure/role-based-administration.md). ## See Also - [Configuration Manager Software Development Kit](../../develop/core/misc/system-center-configuration-manager-sdk.md) - [SMS_MeteredProductRule Server WMI Class](../../develop/reference/apps/sms_meteredproductrule-server-wmi-class.md) + +[Configuration Manager Software Development Kit](../../develop/core/misc/system-center-configuration-manager-sdk.md) +[SMS_MeteredProductRule Server WMI Class](../../develop/reference/apps/sms_meteredproductrule-server-wmi-class.md)