ConnectionOptions con = new ConnectionOptions();
                                        con.EnablePrivileges = true;
                                        con.Impersonation = ImpersonationLevel.Impersonate;
                                        // item.Replace("\"", "") -> remove double quote "PC1234" = PC1234
                                        ManagementScope MScope = new ManagementScope(string.Format("\\\\" + item.Replace("\"", "") + "\\root\\ccm"), con);
                                        MScope.Connect();
                                        ManagementClass MClass = new ManagementClass(MScope.Path.Path, "SMS_CLIENT", null);
                                        // Set up the machine policy.
                                        ManagementBaseObject inParams = MClass.GetMethodParameters("TriggerSchedule");
                                        inParams["sScheduleID"] = sSCCMAction;
                                        // Evaluate machine policy.
                                        MClass.InvokeMethod("TriggerSchedule", inParams, null);
			
		
 
	
Partager