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

            String varType = request.Inputs["Variable Name"].AsString();

            MachineName = request.Inputs["Machine Name"].AsString();

            String resourceID = String.Empty;

            if (request.Inputs.Contains("Resource ID"))
            {
                resourceID = request.Inputs["Resource ID"].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         = null;
                if (resourceID.Equals(String.Empty))
                {
                    col = CMInterop.getSCCMComputer(connection, "", MachineName, "");
                }
                else
                {
                    col = CMInterop.getSCCMComputer(connection, resourceID, "", "");
                }

                foreach (IResultObject c in col)
                {
                    computerObj = c;
                    if (computerObj != null)
                    {
                        //Get Variables from Comoputer Object
                        List <IResultObject> variableCollection = CMInterop.getSCCMComputerVariables(connection, computerObj["ResourceID"].IntegerValue.ToString());

                        if (variableCollection != null)
                        {
                            response.WithFiltering().PublishRange(getComputerVariables(variableCollection));
                            response.Publish("Number of Machine Variables", variableCollection.Count);
                        }
                        response.Publish("Number of Machine Variables", 0);
                    }
                    else
                    {
                        response.LogErrorMessage("Could Not Find Computer " + MachineName);
                    }
                }
            }
        }