Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Does anyone know how to get a list of GPO (Group Policy Objects) from a Windows 2003 domain via PowerShell or some other way if PowerShell can’t do this?

I know that Server 2008 has some cmdlets for Group Polices but how can it be done for a Windows 2003 domain?

Looked on Google but no luck.

Thanks

Gary

share|improve this question

3 Answers 3

try SDM software's group policy cmdlets SDM GPMC PowerShell Cmdlets 1.3

share|improve this answer
    
Good idea, but trying to make the script PowerShell only so we don't need to install different cmdlets on all the customers. But thanks anyway. –  Gary Fawcett Sep 13 '10 at 2:21

You can use the GPMC API to get a list of all GPOs:

$gpm = New-Object -ComObject GPMgmt.GPM
$constants = $gpm.GetConstants()
$domain = $env:USERDOMAIN
$gpmDomain =$gpm.GetDomain($domain ,"", $constants.UseAnyDC)
$gpmSearch = $gpm.CreateSearchCriteria()
$gpmDomain.SearchGPOs($gpmSearch)
share|improve this answer
    
Thanks Shay, I did try that using some examples last week. But I get:- –  Gary Fawcett Sep 5 '10 at 23:15
    
$Constants=$gpm.Getconstants() Method invocation failed because [System.__ComObject] doesn't contain a method named 'Getconstants'. At line:1 char:29 + $Constants=$gpm.Getconstants <<<< () + CategoryInfo : InvalidOperation: (Getconstants:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound –  Gary Fawcett Sep 5 '10 at 23:15

In the end I went with this, used the GPOINFO tool. Not pretty but got what we needed:-


Write-Host "Counting GPO's"
$dom=[System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain()
$PDC=$dom.PdcRoleOwner
gpotool.exe /dc:$PDC > GPOToolRep.txt
$GCReport=Get-Content -Path GPOToolRep.txt
$TextOut+="$($GCReport[4])`n

Thanks for all the responses....Gary

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.