Exemplo n.º 1
0
        public void Execute(IActivityRequest request, IActivityResponse response)
        {
            SCCMServer = settings.SCCMSERVER;
            userName   = settings.UserName;
            password   = settings.Password;

            String machineName  = request.Inputs["Machine Name"].AsString();
            String variableName = request.Inputs["Variable Name"].AsString();


            //Setup WQL Connection and WMI Management Scope
            WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password);

            using (connection)
            {
                //Get Computer Object
                IResultObject computerObj = null;
                IResultObject col         = CMInterop.getSCCMComputer(connection, "", machineName, "");
                foreach (IResultObject c in col)
                {
                    computerObj = c;
                    break;
                }

                if (computerObj != null)
                {
                    CMInterop.deleteSCCMComputerVariable(connection, variableName, computerObj["ResourceID"].StringValue);

                    response.Publish("Variable Name", variableName);
                    response.Publish("Machine Name", machineName);
                }
                else
                {
                    response.LogErrorMessage("Could not find machine " + machineName);
                }
            }
        }