0

SCOM エージェントがメンテナンス モードになっているかどうかをプログラムで確認する方法はありますか。

4

1 に答える 1

0

これは、コマンドレットを呼び出すことで実行できます。

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();
    }
}
于 2010-09-01T00:57:34.547 に答える