private void btOpenCMResExplorer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Type t = System.Reflection.Assembly.GetEntryAssembly().GetType("ClientCenter.Common", false, true);
                System.Reflection.PropertyInfo pInfo = t.GetProperty("Agent");
                SCCMAgent oAgent = (SCCMAgent)pInfo.GetValue(null, null);
                string    sHost  = oAgent.TargetHostname.Split('.')[0];

                Process pRemote = new Process();

                string sServer   = SCCMServer.Replace(@"\", "");
                string sSiteCode = SCCMSiteCode(sServer);

                pRemote.StartInfo.FileName = Properties.Settings.Default.RemoteCommand;
                if (Properties.Settings.Default.RequireAdminConsole)
                {
                    pRemote.StartInfo.WorkingDirectory = System.IO.Path.Combine(SCCMConsolePath, @"bin\i386");
                }
                pRemote.StartInfo.Arguments   = string.Format(Properties.Settings.Default.RemoteArgument, sHost, sServer, sSiteCode);
                pRemote.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                pRemote.Start();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#2
0
        private void btOpenPSConsole_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Type t = System.Reflection.Assembly.GetEntryAssembly().GetType("ClientCenter.Common", true, true);
                System.Reflection.PropertyInfo pInfo = t.GetProperty("Agent");
                SCCMAgent oAgent = (SCCMAgent)pInfo.GetValue(null, null);
                string    sHost  = oAgent.TargetHostname;

                Process pRegedit = new Process();
                pRegedit.StartInfo.FileName    = "Regedit.exe";
                pRegedit.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                pRegedit.Start();
                int pID = pRegedit.Id;

                System.Threading.Thread.Sleep(500);
                System.IntPtr MainHandle = Process.GetProcessById(pID).MainWindowHandle;
                SetForegroundWindow(MainHandle);
                System.Threading.Thread.Sleep(100);
                SendKeys.SendWait("{home}{left}");
                SendKeys.SendWait("%fc");
                System.Threading.Thread.Sleep(600);
                SendKeys.SendWait(string.Format("{0}~", sHost));
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#3
0
        private void btC_Click(object sender, RoutedEventArgs e)
        {
            try{
                if (((FrameworkElement)sender).Tag != null)
                {
                    Type t = System.Reflection.Assembly.GetEntryAssembly().GetType("ClientCenter.Common", false, true);
                    System.Reflection.PropertyInfo pInfo = t.GetProperty("Agent");
                    oAgent = (SCCMAgent)pInfo.GetValue(null, null);
                    string sHost = oAgent.TargetHostname;

                    string sTag   = ((FrameworkElement)sender).Tag.ToString();
                    string sShare = "";
                    switch (sTag)
                    {
                    case "C":
                        sShare = "C$";
                        break;

                    case "Admin":
                        sShare = "Admin$";
                        break;

                    case "WBEM":
                        sShare = @"Admin$\System32\wbem";
                        break;

                    case "ccmsetup":
                        sShare = @"Admin$\ccmsetup\logs";
                        break;

                    case "CCMLOGS":
                        if (oAgent.isConnected)
                        {
                            sShare = oAgent.Client.AgentProperties.LocalSCCMAgentLogPath.Replace(':', '$');
                        }
                        else
                        {
                            sShare = @"Admin$\ccm\logs";
                        }
                        break;

                    default:
                        sShare = sTag;
                        break;
                    }


                    //Connect IPC$ if not already connected (not needed with integrated authentication)
                    //if (!oAgent.ConnectIPC())
                    //    oAgent.ConnectIPC = true;

                    Process Explorer = new Process();
                    Explorer.StartInfo.FileName  = "Explorer.exe";
                    Explorer.StartInfo.Arguments = @"\\" + oAgent.TargetHostname + @"\" + sShare;
                    Explorer.Start();
                }
            }
            catch {}
        }
        private void btAppV46_Click(object sender, RoutedEventArgs e)
        {
            AppVForm fAppv = new AppVForm();
            Type     t     = System.Reflection.Assembly.GetEntryAssembly().GetType("ClientCenter.Common", false, true);

            System.Reflection.PropertyInfo pInfo = t.GetProperty("Agent");
            oAgent        = (SCCMAgent)pInfo.GetValue(null, null);
            fAppv.CMAgent = oAgent;
            fAppv.Show();
        }
示例#5
0
        void toolStripMenuItem1_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
        {
            DataGridViewSelectedRowCollection selectedRows = ((DataGridViewSelectedRowCollection)toolStripMenuItem1.Tag);
            List <string> lHosts = new List <string>();

            foreach (DataGridViewRow dRow in selectedRows)
            {
                try
                {
                    string sHost   = dRow.Cells[0].Value.ToString();
                    int    iOnline = (int)dRow.Cells[7].Value;

                    if (iOnline > 0)
                    {
                        try
                        {
                            if (sHost != null)
                            {
                                if (sHost.Contains('.'))
                                {
                                    lHosts.Add("'" + sHost.Split('.')[0] + "'");
                                }
                                else
                                {
                                    lHosts.Add("'" + sHost + "'");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            dRow.Cells[9].Value = "";
                            dRow.Cells[9].Value = ex.Message.ToString();;
                        }
                    }
                }
                catch { }
            }

            try
            {
                SCCMAgent oAgent  = new SCCMAgent(PSHost, PSHostUser, PSHostPW);
                string    sResult = oAgent.Client.GetStringFromPS("$devices = @(" + string.Join(",", lHosts) + "); " + sPSCode);
                oAgent.disconnect();

                if (!string.IsNullOrEmpty(sResult))
                {
                    MessageBox.Show(sResult, "PowerShell Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch { }
        }
        private void rb_Inst_Click(object sender, RoutedEventArgs e)
        {
            Type t = System.Reflection.Assembly.GetEntryAssembly().GetType("ClientCenter.Common", false, true);

            //Get the Hostname
            //System.Reflection.PropertyInfo pInfo = t.GetProperty("Hostname");

            System.Reflection.PropertyInfo pInfo = t.GetProperty("Agent");
            SCCMAgent oAgent = (SCCMAgent)pInfo.GetValue(null, null);

            Install oIntsWin = new Install(oAgent);

            oIntsWin.ShowDialog();
        }
        private void btQuickScan_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Type t = System.Reflection.Assembly.GetEntryAssembly().GetType("ClientCenter.Common", false, true);
                System.Reflection.PropertyInfo pInfo = t.GetProperty("Agent");
                oAgent = (SCCMAgent)pInfo.GetValue(null, null);
                string sHost = oAgent.TargetHostname;

                oAgent.Client.GetStringFromPS("Set-MpPreference -DisableRealtimeMonitoring $false");
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#8
0
        // Method to trigger an already advertised task sequence immediatly.
        public static void TSTrigger(string Hostname, string TSName)
        {
            // Initilize some variables that we will need later on.
            softwaredistribution.CCM_SoftwareDistribution selectedAdvert = null;

            // Connects to the SCCM Agent on the target machine.
            SCCMAgent oAgent = ConnectAgent(Hostname);

            // Adds all adverts available on target to a list.
            var allAdverts = oAgent.Client.SoftwareDistribution.Advertisements_(true);

            Console.WriteLine("The host '" + Hostname + "' has the following advertisements assigned to it:");
            //Console.WriteLine("------------------------------");
            // Loops through all the adverts and 1) Prints them; 2) Selects the targeted advert via the supplied TSName var and prepares it to be triggered.
            foreach (softwaredistribution.CCM_SoftwareDistribution adv in allAdverts)
            {
                Console.WriteLine("-->  " + adv.PKG_Name);
                if (adv.PKG_Name == TSName)
                {
                    selectedAdvert = adv;
                }
            }
            Console.WriteLine();

            // Shows the selected advert if it exists, catches the error if it doesn't.
            try
            {
                Console.WriteLine("The following advertisement has been selected for install:");
                Console.WriteLine("-->  " + selectedAdvert.PKG_Name);
                Console.WriteLine();
            }
            catch
            {
                Console.WriteLine("<ERROR> The advertisment '" + TSName + "' was not found!");
                System.Environment.Exit(1);
            }


            // Sets the selected advert to immediatly start.
            Console.WriteLine("Triggering " + selectedAdvert.PKG_Name + "...");
            selectedAdvert.TriggerSchedule(true);
            Console.WriteLine("Advertisment '" + selectedAdvert.PKG_Name + "' triggered.");
            Console.WriteLine();
        }
 private void btOpenPSConsole_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Type t = System.Reflection.Assembly.GetEntryAssembly().GetType("ClientCenter.Common", false, true);
         System.Reflection.PropertyInfo pInfo = t.GetProperty("Agent");
         SCCMAgent oAgent   = (SCCMAgent)pInfo.GetValue(null, null);
         string    sHost    = oAgent.TargetHostname;
         Process   COMPMGMT = new Process();
         COMPMGMT.StartInfo.FileName    = Environment.ExpandEnvironmentVariables("msinfo32.exe");
         COMPMGMT.StartInfo.Arguments   = string.Format("/computer {0}", sHost);
         COMPMGMT.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
         COMPMGMT.Start();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
示例#10
0
 // Method to connect to an SCCM Agent on a machine, specified by hostname.
 public static SCCMAgent ConnectAgent(string Hostname)
 {
     Console.WriteLine("Attempting to initiate connection to SCCM Agent on host '" + Hostname + "'...");
     try
     {
         SCCMAgent agent = new SCCMAgent(Hostname);
         if (agent.isConnected)
         {
             Console.WriteLine("Successfully connected to SCCM Agent on host '" + Hostname + "'!");
             Console.WriteLine();
             return(agent);
         }
     } catch
     {
         Console.WriteLine("<ERROR> Unable to connect to SCCM Agent on host '" + Hostname + "'!");
         System.Environment.Exit(1);
     }
     return(null);
 }
示例#11
0
        private void btOpenMSRA_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Type t = System.Reflection.Assembly.GetEntryAssembly().GetType("ClientCenter.Common", false, true);
                System.Reflection.PropertyInfo pInfo = t.GetProperty("Agent");
                SCCMAgent oAgent = (SCCMAgent)pInfo.GetValue(null, null);
                string    sHost  = oAgent.TargetHostname;

                Process pRemote = new Process();

                pRemote.StartInfo.FileName    = Properties.Settings.Default.RemoteCommand;
                pRemote.StartInfo.Arguments   = string.Format(Properties.Settings.Default.RemoteArgument, sHost);
                pRemote.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                pRemote.Start();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        void PSItem_Click(object sender, EventArgs e)
        {
            try
            {
                //Get PS from File
                string sFile = ((RibbonButton)sender).Tag.ToString();

                StreamReader streamReader = new StreamReader(sFile, Encoding.UTF8);
                string       text         = streamReader.ReadToEnd();
                streamReader.Close();


                Type t = System.Reflection.Assembly.GetEntryAssembly().GetType("ClientCenter.Common", false, true);

                //Get Agent
                System.Reflection.PropertyInfo pInfo = t.GetProperty("Agent");
                oAgent = (SCCMAgent)pInfo.GetValue(null, null);

                //Run PS and trace result...
                string sRes = oAgent.Client.GetStringFromPS(text);
                oAgent.PSCode.TraceInformation(sRes);
            }
            catch { }
        }
示例#13
0
 public Install(SCCMAgent oAgt)
 {
     InitializeComponent();
     InstPanel.oAgent = oAgt;
 }