首页 > 解决方案 > Active Directory - c# 中的 DN 转发器

问题描述

我们可以检查 C# .NET 中每个域控制器上配置的 Dns 转发器吗?找不到任何支持这一点的类。

请协助。

标签: c#dnsactive-directoryldap

解决方案


使用 WSManConnectionInfo 和 Runspace,我可以获取所需的详细信息。

        WSManConnectionInfo connInfo = new WSManConnectionInfo(new Uri("http://ServerName:5985/wsman"));
        Collection<PSObject> output = null;
        string command = "Get-DnsServerForwarder";
        using (Runspace remoteRS = RunspaceFactory.CreateRunspace(connInfo))
        {
            remoteRS.Open();
            using (var pShell = PowerShell.Create())
            {
                pShell.Commands.AddCommand(command);
                output = pShell.Invoke();
            }
        }

推荐阅读