You get the current management point for a Configuration Manager 2007 client by calling the SMSClientClass object SetCurrentManagementPoint method. You set the current management point for a client by calling the SMSClientClass object GetCurrentManagementPoint method.

Note
With SetCurrentManagementPoint you can set the management point with either the IP address or with the computer name of the management point.

To get and set the management point for a Configuration Manager client

  1. Get the Configuration Manager client configuration object (SMSClientClass).

  2. From the SMSClientClass object, call GetCurrentManagementPoint to get the client's current management point.

  3. From the SMSClientClass object, call SetCurrentManagementPoint to set the client's current management point.

Example

The following example method sets the management point for a Configuration Manager client by using the SMSClientClass object SetCurrentManagementPoint method. The example sets the management point by using the computer name. To set the management point with the IP address, you pass 1 (SmsClient_MPProtocolEnum.SmsClient_MPProtocol_OS) as the second parameter. The following example also displays the current and updated management point using GetCurrentManagmentPoint.

For information about calling the sample code, see How to Call Configuration Manager COM Automation Objects.

Visual Basic Script  Copy Code
Sub SetCurrentManagementPoint (computerName)

	On Error Resume Next

	Dim oSMSClient

	Set oSMSClient = CreateObject ("Microsoft.SMS.Client")

	If Err.Number <>0 Then 
		WScript.Echo "Could not create SMS Client Object - quitting"
		Exit Sub
	End If

	WScript.Echo "Current Management Point is : " & _
		oSMSClient.GetCurrentManagementPoint

	' Set management point to given computer name.
	oSMSClient.SetCurrentManagementPoint computerName,0

	WScript.Echo "Current Management Point is now : " & _
		oSMSClient.GetCurrentManagementPoint

	Set oSMSClient=Nothing

End Sub
C#  Copy Code
public void SetCurrentManagementPoint(string computerName)
{
	try
	{
		SmsClientClass client = new SmsClientClass();

		Console.WriteLine("Current management point is: " + 
			client.GetCurrentManagementPoint());

		client.SetCurrentManagementPoint(computerName,
			_SmsClient_MPProtocolEnum.SmsClient_MPProtocol_OS);

		Console.WriteLine("Current management point is now: " + 
			 client.GetCurrentManagementPoint());
}
	catch (COMException e)
	{
		Console.WriteLine("Failed to set the management point " + e.Message);
		throw;
}
}

The example method has the following parameters:

Parameter Type Description

newSite

  • Managed: String

  • VBScript: String

  • The new management point for the client.

Compiling the Code

This C# example requires:

Namespaces

System

System.Collections.Generic

System.Text

System.Runtime.InteropServices

SmsClientLib

Assembly

SmsClientLib

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


Send comments about this topic to Microsoft.