none
Calling the "Deploy Configuration Baselines" SCCM Dialog from C# code (i.e. in a SCCM console extension) RRS feed

  • Question

  • Hi,

    We have a SCCM “console extension” (written in C#/WPF/.Net4.5).See secRMM SCCM console extension 
    The SCCM “console extension”’s purpose is to secure (via SCCM compliance setting policies) and to audit (via SCCM reports and SCCM Dashboard/Charts) the use of “removable storage” devices (i.e. USB thumb drives, etc,) directly with the SCCM console.
    The SCCM “console extension” creates a SCCM “compliance setting” which is just like any other SCCM “compliance setting” meaning there is a “baseline Configuration Item” (CI) and multiple child CIs.
    The current version of the SCCM “console extension” has been in production for several years and works as expected.
    The current version of the SCCM “console extension” requires that the end-user use the “Deploy” button that is under the “Assets and Compliance”-> “Compliance Settings”->”Configuration Baselines” tree within the SCCM console (screenshot below).

    SCCM Compliance Settings Deploy button on menu ribbon

    When you click the “Deploy” button, the following SCCM Dialog is displayed (i.e. the SCCM “Deploy Configuration Baselines” dialog):

    SCCM Deploy Configuration Baselines Dialog

    We are updating the SCCM “console extension” based on a request from an existing user.
    What we would like the new functionality of the SCCM “console extension” to do is to programmatically (in C# SCCM console extension code) call the SCCM “Deploy Configuration Baselines” dialog when the user saves a new SCCM “compliance setting”.

    Below is the code we came up with, but the dialog does not display (but no exceptions or failures either).

            public bool CallDeploymentDialog(
                string stringSecRMMPolicySetDescription_in)
            {
                bool l_boolReturnCode = false;
    
                //see \Program Files (x86)\
                //    Microsoft Configuration Manager\
                //    AdminConsole\XmlStorage\Forms\
                //    AssignBaselineDialog.xml
                string l_stringDialogId = "AssignBaselineDialog";
                IResultObject l_IResultObject =
                    GetSMS_ConfigurationBaselineInfo(
                        stringSecRMMPolicySetDescription_in);
                PropertyDataUpdated l_PropertyDataUpdated = PropertyDataUpdatedMethod;
                ScopeNode l_ScopeNode =
                    secRMMSCCM2012ConsoleExtensionViewDescriptions.m_ScopeNode;
                SmsDialogData l_SmsDialogData =
                    new SmsDialogData(
                        l_stringDialogId, 
                        l_IResultObject, 
                        l_PropertyDataUpdated,
                        l_ScopeNode, 
                        false);
                SmsPageData l_SMSPageData =
                    new SmsPageData(l_SmsDialogData);
                AssignBaselinePageControl l_AssignBaselinePageControl =
                    new AssignBaselinePageControl(l_SMSPageData);
                l_AssignBaselinePageControl.InitializePageControl();
                l_AssignBaselinePageControl.Show();
                MessageBox.Show("test");
    
                return (l_boolReturnCode);
            }
    

    To try to figure out the solution, we hooked the call stack at the point where the end user clicks the Deploy button (see screenshot below) and it seems we will need to have our code make the proper call which is lower in the call stack. 

    Call Stack for calling SCCM “Deploy Configuration Baselines” dialog

    I don’t know the answer (hence this post 😊) but maybe Microsoft.EnterpriseManagement.UI.ConsoleFramework.dll!Microsoft.EnterpriseManagement.ConsoleFramework.WindowTaskHandler.WindowTaskOperation.ExecuteTask()

    I know that the SCCM SDK mostly talks about using the XML tree \Program Files (x86)\Microsoft Configuration Manager\AdminConsole\XmlStorage\... under the SCCM console directory but we need to make the call within the C# code.  Maybe the answer is to create an “Action” (from the XML) invoker but again, not sure how to accomplish that from within the C#.

    Here’s hoping that I have made it more complicated than it is (fingers crossed)!
    Any help/advice would be greatly appreciated!
    Thanks in advance,

    Tony LaMark


    Anthony LaMark

    Saturday, June 20, 2020 2:07 AM

Answers

  • Hi,

    The fix to get the ViewUtility.ExecutAction working was to use the context and scopenode from the SCCM console extension view controller (which is a subclass of the SCCM OverviewControllerBase class where the context and scopenode come from).

    The code below is now working.

            public bool CallDeploymentDialog(
                string stringSecRMMPolicySetDescription_in)
            {
                bool l_boolReturnCode = false;
    
                ActionDescription l_ActionDescription = 
                    GetActionDescription();
                object l_objectContext = 
                    secRMMSCCM2012ConsoleExtensionViewController.m_Context;
                ScopeNode l_ScopeNode =
                    secRMMSCCM2012ConsoleExtensionViewController.m_ScopeNode;
                IResultObject l_IResultObject =
                    GetSMS_ConfigurationBaselineInfo(
                        stringSecRMMPolicySetDescription_in);
    
                if ((l_ActionDescription!=null) &&
                    (l_objectContext!=null) &&
                    (l_ScopeNode!=null) &&
                    (l_IResultObject!=null))
                {
                    ViewUtility.ExecuteAction(l_ActionDescription,
                                              l_objectContext,
                                              l_ScopeNode,
                                              l_IResultObject);
                    l_boolReturnCode = true;
                }
    
                return (l_boolReturnCode);
            }
    


    Anthony LaMark

    • Marked as answer by ALaMark Sunday, June 21, 2020 7:41 PM
    Sunday, June 21, 2020 7:41 PM

All replies

  • Hi,

    Studying more code, I am trying another approach (see code below).
    However, I can't figure out what the context object should be for the ViewUtility.ExecuteAction (2nd parameter).
    I am trying to use the FrameworkServices.GetService api but I keep getting null back.
    The FrameworkServices.GetService takes a single parameter of Type.
    Again, any help/advice if greatly appreciated.

            public bool CallDeploymentDialog(
                string stringSecRMMPolicySetDescription_in)
            {
                bool l_boolReturnCode = false;
    
                ActionDescription l_ActionDescription = GetActionDescription();
                object l_objectContext = FrameworkServices.GetService(typeof(IContainer));
                ScopeNode l_ScopeNode =
                    secRMMSCCM2012ConsoleExtensionViewDescriptions.m_ScopeNode;
                IResultObject l_IResultObject =
                    GetSMS_ConfigurationBaselineInfo(
                        stringSecRMMPolicySetDescription_in);
    
                ViewUtility.ExecuteAction(l_ActionDescription,
                                          l_objectContext,
                                          l_ScopeNode,
                                          l_IResultObject);
    
                return (l_boolReturnCode);
            }
    


    Anthony LaMark

    Saturday, June 20, 2020 7:12 PM
  • Hi,

    The fix to get the ViewUtility.ExecutAction working was to use the context and scopenode from the SCCM console extension view controller (which is a subclass of the SCCM OverviewControllerBase class where the context and scopenode come from).

    The code below is now working.

            public bool CallDeploymentDialog(
                string stringSecRMMPolicySetDescription_in)
            {
                bool l_boolReturnCode = false;
    
                ActionDescription l_ActionDescription = 
                    GetActionDescription();
                object l_objectContext = 
                    secRMMSCCM2012ConsoleExtensionViewController.m_Context;
                ScopeNode l_ScopeNode =
                    secRMMSCCM2012ConsoleExtensionViewController.m_ScopeNode;
                IResultObject l_IResultObject =
                    GetSMS_ConfigurationBaselineInfo(
                        stringSecRMMPolicySetDescription_in);
    
                if ((l_ActionDescription!=null) &&
                    (l_objectContext!=null) &&
                    (l_ScopeNode!=null) &&
                    (l_IResultObject!=null))
                {
                    ViewUtility.ExecuteAction(l_ActionDescription,
                                              l_objectContext,
                                              l_ScopeNode,
                                              l_IResultObject);
                    l_boolReturnCode = true;
                }
    
                return (l_boolReturnCode);
            }
    


    Anthony LaMark

    • Marked as answer by ALaMark Sunday, June 21, 2020 7:41 PM
    Sunday, June 21, 2020 7:41 PM
  • Hi,

    Thank you very much for the update and we're glad the problem is solved now. If you have any questions in future, we warmly welcome you to post in this forum again.

    Have a nice day!

    Regards,
    Allen Liu

    Please remember to mark the replies as answers if they help.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, June 22, 2020 2:56 AM