How to Create a State Migration Point Role
Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2
You create the state migration point role, in Microsoft System Center Configuration Manager 2007, by creating an instance of SMS_SCI_SysResUse Server WMI Class and providing the property values in the following table.
Property | Description |
---|---|
RoleName |
Name of the role. For a state migration point, the value is SMS State Migration Point. |
SiteCode |
The site code for the site. |
NALPath |
The network abstraction layer (NAL) path to the state migration point. For more information, see PackNALPath Method in Class SMS_NAL_Methods. |
NALType |
The resource type. For a state migration point, this should be Windows NT Server. |
You will also need to set initial values for the following embedded properties and embedded property lists.
Name | Description |
---|---|
Server Remote Name |
The server that has the state migration point. Embedded property. |
SMPQuiesceState |
Sets the restore-only mode. For more information, see How to Set the Restore-Only Mode for a State Migration Point. Embedded property. |
SMPStoreDeletionDelayTimeInMinutes |
Sets the deletion policy. For more information, see How to Set the Deletion Policy for a State Migration Point. Embedded property. |
SMPStoreDeletionCycleTimeInMinutes |
Sets the deletion policy. For more information, see How to Set the Deletion Policy for a State Migration Point. |
Directories |
Lists the state migration point folders. For more information, see How to Add a State Migration Point Folder. |
To create a state migration point role
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
Create an instance of SMS_SCI_SysResUse Server WMI Class.
Populate the properties listed above.
Commit the SMS_SCI_SystResUse object.
Example
The following example method creates a state migration point from the supplied site code and NAL path. Some helper functions are provided for writing the embedded properties and embedded property lists to the site control file. The example also makes use of the other state migration point code snippets to set various role values.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
public void CreateSmpRole(
WqlConnectionManager connection,
string serverName,
string siteCode,
string nalPath)
{
try
{
// Create the state migration point resource object.
IResultObject smpRole = connection.CreateInstance("SMS_SCI_SysResUse");
smpRole["RoleName"].StringValue = "SMS State Migration Point";
// Set the state migration point properties.
smpRole["SiteCode"].StringValue = siteCode;
smpRole["NALPath"].StringValue = nalPath;
smpRole["NALType"].StringValue = "Windows NT Server";
// Create the embedded property and property lists.
this.WriteScfEmbeddedProperty(smpRole, "Server Remote Name", 0, serverName, string.Empty);
this.WriteScfEmbeddedProperty(smpRole, "SMPQuiesceState", 1, string.Empty, string.Empty);
this.WriteScfEmbeddedProperty(smpRole, "SMPStoreDeletionDelayTimeInMinutes", 0, string.Empty, string.Empty);
this.WriteScfEmbeddedProperty(smpRole, "SMPStoreDeletionCycleTimeInMinutes", 0, string.Empty, string.Empty);
this.WriteScfEmbeddedPropertyList(smpRole, "Directories", null);
// Commit the site role.
smpRole.Put();
// Use SDK snippets to populate some values.
this.AddSmpFolder(connection, @"C:\temp", 100, 10, 1, serverName, siteCode);
this.SetRestoreOnlyMode(connection, serverName, siteCode, true);
this.SetDeletionPolicy(connection, serverName, siteCode, 10);
}
catch (SmsException e)
{
Console.WriteLine("Failed to create the state migration point: " + e.Message);
throw;
}
}
public void WriteScfEmbeddedPropertyList(
IResultObject resource,
string propertyListName,
string[] values
)
// Create an embedded property list for the supplied resource.
{
Dictionary<string, IResultObject> EmbeddedPropertyList = resource.EmbeddedPropertyLists;
// Get the property list, or create it.
IResultObject ropl;
if (EmbeddedPropertyList.ContainsKey(propertyListName))
{
ropl = EmbeddedPropertyList[propertyListName];
}
else
{
ConnectionManagerBase connection = resource.ConnectionManager;
ropl = connection.CreateEmbeddedObjectInstance("SMS_EmbeddedPropertyList");
EmbeddedPropertyList.Add(propertyListName, ropl);
}
// Set the property list properties.
ropl["PropertyListName"].StringValue = propertyListName;
ropl["Values"].StringArrayValue = values;
resource.EmbeddedPropertyLists = EmbeddedPropertyList;
}
public void WriteScfEmbeddedProperty(
IResultObject resource,
string propertyName,
int value,
string value1,
string value2)
{
// Properties
// Server remote name
Dictionary<string, IResultObject> EmbeddedProperties = resource.EmbeddedProperties;
// Get the property, or create it.
IResultObject ro;
if (EmbeddedProperties.ContainsKey(propertyName))
{
ro = EmbeddedProperties[propertyName];
}
else
{
ConnectionManagerBase connection = resource.ConnectionManager;
ro = connection.CreateEmbeddedObjectInstance("SMS_EmbeddedProperty");
EmbeddedProperties.Add(propertyName, ro);
}
ro["PropertyName"].StringValue = propertyName;
ro["Value"].IntegerValue = value;
ro["Value1"].StringValue = value1;
ro["Value2"].StringValue = value2;
resource.EmbeddedProperties = EmbeddedProperties;
}
The example method has the following parameters:
Parameter |
Type |
Description |
connection |
Managed: WqlConnectionManager |
A valid connection to the SMS Provider. |
serverName |
Managed: String |
The Configuration Manager server that the state migration point is running on. |
siteCode |
Managed: String |
The Configuration Manager site code. |
nalPath |
Managed: String |
The NAL path to the state migration point. For example, |
Compiling the Code
The C# example has the following compilation requirements:
Namespaces
System
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
Assembly
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
Robust Programming
For more information about error handling, see About Configuration Manager Errors.
Security
For more information about securing Configuration Manager applications, see About Securing Configuration Manager Applications.
See Also
Concepts
SMS_SCI_SysResUse Server WMI Class
PackNALPath Method in Class SMS_NAL_Methods
About Operating System Deployment Site Role Configuration
Configuration Manager Operating System Deployment
Configuration Manager Programming Fundamentals
Configuration Manager Site Control File
Operating System Deployment Site Role Configuration
How to Add a State Migration Point Folder
How to Set the Deletion Policy for a State Migration Point
How to Set the Restore-Only Mode for a State Migration Point
How to Read and Write to the Configuration Manager Site Control File by Using Managed Code
How to Read and Write to the Configuration Manager Site Control File by Using WMI