在C#中获取OU的组策略属性

时间:2016-05-03 00:40:00

标签: c# active-directory msdn group-policy

我正在尝试在c#中重新创建以下powershell代码。这会让我回头

Get-ADOrganizationalUnit -Filter *| Get-GPInheritance | Where-Object {$_.GPOInheritanceBlocked}

我能提出的最接近的事情(并且它不起作用)是这样的:

using Microsoft.GroupPolicy.Commands;  
using System.Management.Automation;

GetGPInheritanceCommand inheritance = new GetGPInheritanceCommand();
inheritance.Domain = domain;
inheritance.Target = "ou=brandon,dc=centoso,dc=com";
// I can't figure out where to go from here. I have tried the following:

// The below returns "d__0"
var res = inheritance.Invoke();
Console.WriteLine(res);

// The below attempt just throws an error.
foreach (var res in inheritance.Invoke())
{
     Console.WriteLine(res);
}

在涉及C#时,MSDN对于Active Directory的组策略非常模糊。

0 个答案:

没有答案