This project has moved. For the latest updates, please go here.

C# Sample

The following C# Code will return the assigned Site Code and the corresponding Powershell command.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using sccmclictr;
using System.Management.Automation.Runspaces; 
using System.Diagnostics;

namespace Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            sccmclictr.automation.SCCMAgent oAgent = 
                new sccmclictr.automation.SCCMAgent("127.0.0.1", null, null);
            oAgent.ConnectionInfo.AuthenticationMechanism = 
                AuthenticationMechanism.Default;

            //To send the Powershell code to the console...
            oAgent.PSCode.Listeners.Add(new TextWriterTraceListener(Console.Out));
            
            //Connect the SCCM Agent
            oAgent.connect();

            Console.WriteLine("Assigned Site: " + 
                oAgent.Client.AgentProperties.AssignedSite);

            Console.ReadKey();
        }
    }
}

SCCM 2012 Client Center Automation Class Library

ClassDiagram1.png
ClassDiagram1.png

Last edited Mar 5, 2013 at 8:32 AM by rzander, version 10

Comments

No comments yet.