我正在尝试在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的组策略非常模糊。