public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; int referenceID = (int)request.Inputs["Reference Computer Resource ID"].AsUInt32(); int destinationID = (int)request.Inputs["Destination Computer Resource ID"].AsUInt32(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password); using (connection) { CMInterop.associateComputer(connection, referenceID, destinationID); IResultObject col = null; col = CMInterop.getSCCMComputer(connection, Convert.ToString(destinationID), "", ""); if (col != null) { response.WithFiltering().PublishRange(getObjects(col)); } response.Publish("Number of Systems", ObjCount); } }
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); } } } }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String argType = request.Inputs["Argument Type"].AsString(); String argString = request.Inputs["Argument String"].AsString(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password); using (connection) { IResultObject col = null; //Get Computer Collection switch (argType) { case "ResourceID": col = CMInterop.getSCCMComputer(connection, argString, "", ""); break; case "NetbiosName": col = CMInterop.getSCCMComputer(connection, "", argString, ""); break; case "DomainName": col = CMInterop.getSCCMComputer(connection, "", "", argString); break; case "Query": col = CMInterop.getSCCMObject(connection, "SMS_R_System", argString); break; } if (col != null) { response.WithFiltering().PublishRange(getComputers(col)); } response.Publish("Number of Systems", SystemCount); } }
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); } }
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); } } }
public void Execute(IActivityRequest request, IActivityResponse response) { SCCMServer = settings.SCCMSERVER; userName = settings.UserName; password = settings.Password; String pkgID = request.Inputs["Existing Package ID"].AsString(); String selectionMethod = request.Inputs["Distribution Point Selection Method"].AsString(); String criteria = request.Inputs["Selection Criteria"].AsString(); String NALPathQuery = request.Inputs["NAL Path Query (Single DP)"].AsString(); //Setup WQL Connection and WMI Management Scope WqlConnectionManager connection = CMInterop.connectSCCMServer(SCCMServer, userName, password); using (connection) { switch (selectionMethod) { case "Single Distribution Point": if (criteria.Equals(String.Empty) || NALPathQuery.Equals(String.Empty)) { response.LogErrorMessage("Must use optional property 'Selection Criteria' with Single DP Selection. Criteria should be DP Name to refresh Package at. Must also provide a NALPathQuery"); } else { IResultObject obj = CMInterop.getSCCMComputer(connection, "", criteria, ""); foreach (IResultObject comp in obj) { system DP = new system(comp); bool success = false; foreach (String siteCode in DP.AgentSite.Split(',')) { try { CMInterop.refreshSCCMPackageAtDistributionPoint(connection, pkgID, siteCode, criteria, NALPathQuery); success = true; break; } catch { } } if (!success) { throw new Exception("Failed to remove package to DP"); } } } break; case "Distribution Point Group": if (criteria.Equals(String.Empty)) { response.LogErrorMessage("Must use optional property 'Selection Criteria' with DP Group Selection. Criteria should be DP Group Name to refresh Package at"); } else { CMInterop.refreshSCCMPackageAtDistributionPointGroup(connection, pkgID, criteria); } break; case "All Distribution Points": CMInterop.refreshSCCMPackageAtAllDistributionPoints(connection, pkgID); break; } response.Publish("Package ID", pkgID); } }
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(); String variableValue = request.Inputs["Variable Value"].AsString(); String machineSite = String.Empty; String resourceID = String.Empty; if (request.Inputs.Contains("Machine Site")) { machineSite = request.Inputs["Machine Site"].AsString(); } 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) { if (machineSite.Equals(String.Empty)) { String SiteCode = determineComputerSiteCode(computerObj); CMInterop.createSCCMComputerVariable(connection, SiteCode, variableName, variableValue, false, computerObj["ResourceID"].IntegerValue); } else { CMInterop.createSCCMComputerVariable(connection, machineSite, variableName, variableValue, false, computerObj["ResourceID"].IntegerValue); } response.Publish("Variable Name", variableName); response.Publish("Variable Value", variableValue); response.Publish("Machine Name", machineName); } else { response.LogErrorMessage("Could not find machine " + machineName); } } } }