【问题标题】:Detect maintenance mode scom agent (aka MOM)检测维护模式 scom 代理(又名 MOM)
【发布时间】:2023-04-06 08:30:01
【问题描述】:

是否可以通过编程方式确定 SCOM 代理是否处于维护模式。

【问题讨论】:

    标签: mom


    【解决方案1】:

    这可以通过调用 cmdlet 来完成。

    Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client
    Get-Agent 
    

    添加引用 System.Management.Automation.dll

    public class ExecuteCmdlet
    {
        public static InitialSessionState state;
        public static RunspacePool pool;
    
        static ExecuteCmdlet()
        {
            Console.WriteLine("Creating Initial State");
            state = InitialSessionState.CreateDefault();
            try
            {
                PSSnapInException ex = null;
                state.ImportPSSnapIn("Microsoft.EnterpriseManagement.OperationsManager.Client", out ex);
            }
            catch { }
    
            pool = RunspaceFactory.CreateRunspacePool(state);
            pool.SetMinRunspaces(3);
            pool.SetMaxRunspaces(10);
            pool.Open();
        }
    
         public static Collection<PSObject> Execute(string cmd)
        {
            PowerShell gpc = PowerShell.Create();
            // Specify the runspace to use and add commands.
            gpc.RunspacePool = pool;
            gpc.AddCommand(cmd);
            return gpc.Invoke();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多