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

            String netBiosName = null;
            String macAddress  = null;
            String smBiosGuid  = null;

            netBiosName = request.Inputs["Netbios Name"].AsString();

            if (request.Inputs.Contains("SM Bios GUID"))
            {
                smBiosGuid = request.Inputs["SM Bios GUID"].AsString();
            }
            if (request.Inputs.Contains("MAC Address"))
            {
                macAddress = request.Inputs["MAC Address"].AsString();
            }

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

            using (connection)
            {
                int resourceID = CMInterop.addNewComputer(connection, netBiosName, smBiosGuid, macAddress);

                IResultObject col = null;
                col = CMInterop.getSCCMComputer(connection, Convert.ToString(resourceID), "", "");

                if (col != null)
                {
                    response.WithFiltering().PublishRange(getObjects(col));
                }
                response.Publish("Number of Systems", ObjCount);
            }
        }