To create an SCCM console snap-in with C#, you will need to follow these steps:
- Open Visual Studio and create a new C# project.
- In the project, add references to the following assemblies:
- Microsoft.ConfigurationManagement.ManagementProvider
- Microsoft.ConfigurationManagement.ManagementConsole
- In the project, create a new class that derives from the
Microsoft.ConfigurationManagement.ManagementConsole.SnapIn
class and implement the required methods. - In the
OnInitialize()
method, specify the display name and the description for the snap-in. - In the
OnInitialize()
method, create an instance of theMicrosoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
class and assign it to theWqlQueryEngine
property of the snap-in. - In the
OnInitialize()
method, create an instance of theMicrosoft.ConfigurationManagement.ManagementConsole.ScopeNode
class and assign it to theRootNode
property of the snap-in. This will be the root node of the console tree for the snap-in. - In the
OnInitialize()
method, add any child nodes to the root node that you want to appear in the console tree. - In the
OnInitialize()
method, add any views or actions that you want to be available in the snap-in.
Here is an example of what the code might look like:
using Microsoft.ConfigurationManagement.ManagementProvider;
using Microsoft.ConfigurationManagement.ManagementConsole;
public class MySnapIn : SnapIn
{
protected override void OnInitialize()
{
// Set the display name and description for the snap-in.
this.DisplayName = "My Snap-In";
this.Description = "This is my custom SCCM snap-in.";
// Create an instance of the WqlQueryEngine class and assign it to the WqlQueryEngine property.
this.WqlQueryEngine = new WqlQueryEngine();
// Create an instance of the ScopeNode class and assign it to the RootNode property.
this.RootNode = new ScopeNode();
// Add child nodes to the root node as needed.
// Add views and actions to the snap-in as needed.
}
}
C#For more information and detailed instructions on creating SCCM console snap-ins, see the documentation for the Microsoft.ConfigurationManagement.ManagementConsole.SnapIn
class.