lazywinadmin / AdsiPS

PowerShell module to interact with Active Directory using ADSI and the System.DirectoryServices namespace (.NET Framework)
http://www.lazywinadmin.com
MIT License
193 stars 48 forks source link

Group Policy Objects #9

Open lazywinadmin opened 8 years ago

lazywinadmin commented 8 years ago

Is there anyway to retrieve Group policy objects, Links, permissions, using .NET ?

I already have some basic code here Get-ADSIGroupPolicyObject but it is far from perfect.

I would like to have the same approach as Get-ADSIUser, that I'm reusing in Remove-ADSIUser, Unlock-ADSIUser, Enable-ADSIUSer, Disable-ADSIUser

MickyBalladelli commented 8 years ago

There is maybe a way by using the GPMC assemblies, example:

$assembly=[reflection.assembly]::Load("Microsoft.GroupPolicy.Management, Version=2.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35")
$domain = new-object Microsoft.GroupPolicy.GPDomain
$domain.GetAllGpos()

More about the namespace: Microsoft.GroupPolicy namespace

lazywinadmin commented 8 years ago

Thanks @MickyBalladelli ! Yeah I guess I could take this approach I was just hoping i could rely on .net