Creating a security scope in System Center 2012 R2 Configuration Manager is simple. All security scopes are defined by the SMS_SecuredCategory Windows Management Instrumentation (WMI) class. Only two properties are required when you are creating a new security scope, the name and description.

To create a new security scope

  1. Set up a connection to the SMS Provider.

  2. Create an instance of the SMS_SecuredCategory WMI class

  3. Set the CategoryName and CategoryDescription properties.

  4. Save the security scope.

Example

The following example creates a new security scope:

Visual Basic Script  Copy Code
Sub CreateSecurityScope(connection, scopeName, scopeDescription)

	Dim scope

	' Create a new security scope instance.
	Set scope = connection.Get("SMS_SecuredCategory").SpawnInstance_()

	' Set the required properties.
	scope.CategoryName = scopeName	scope.CategoryDescription = scopeDescription

	' Save the security scope.
	scope.Put_

End Sub
C#  Copy Code
public void CreateSecurityScope(WqlConnectionManager connection, string scopeName, string scopeDescription)
{
	// Create a new security scope instance.
	IResultObject secScope = connection.CreateInstance("SMS_SecuredCategory");

	// Set the required properties.
	secScope.Properties["CategoryName"].StringValue = scopeName;
	secScope.Properties["CategoryDescription"].StringValue = scopeDescription;

	// Save the security scope.
	secScope.Put();
}

The example method has the following parameters:

Parameter

Type

Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

scopeName

String

The name of security scope.

scopeDescription

String

The description of security scope.

Compiling the Code

The C# example requires:

Namespaces

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

See Also