[gptalk] Get-SDMgpo only returning 3/4

  • From: "Kevin Gay" <kevin.gay@xxxxxxxxx>
  • To: <gptalk@xxxxxxxxxxxxx>
  • Date: Wed, 25 Jun 2008 10:46:17 -0500

I'm using Powershell to create backups of all our GPO's, basically a
daily script that runs and drops them into a folder with the GPO's name
as the folder name. I've attached links and the script at the bottom if
anyone would like to use it. But the real problem is that Get-SDMgpo
only retrieves about 3/4 of all the GPOs in the domain, we have 61
GPO's, running Get-SDMgpo * (which grabs them all) only returns 48. So
I'm wondering if anyone else has had this problem and if they resolved
it. I'm also using the free download of the cmdlets.


http://www.gpoguy.com/powershell.htm - explanation of the cmdlets and
download location. You'll need to see the howto so you can add the
cmdlets to powershell.

http://gnuwin32.sourceforge.net/packages/grep.htm - for grep used in the
script, I just placed the files in system32.




#Add-PSSnapin SDMSoftware.PowerShell.GPMC #uncomment in case you get an
error saying Get-SDMgpo is not understood.

$gpmList = Get-SDMgpo * | grep "DisplayName"


$strSavePath = \\server\share" 


#             the log doesn't seem to work as well as I expected it to.

$Date = Get-Date -format MM-dd-yyyy

$Logs = \\server\share\Logs\" + $Date + ".txt"


foreach ($gpmGPOName in $gpmList)



#             Essentially this is performing an InStr() and then a

#   so it can grab only the GPO name.

                $Index = $gpmGPOName.indexof(":") + 2

                $Length = $gpmGPOName.length - $Index


#             See if it outputs correctly

#             echo $gpmGPOName.substring($Index, $Length) 

                $gpmName = $gpmGPOName.substring($Index, $Length)

                echo $gpmName


#             put together the full path            

                $strLocation = $strSavePath + "\" + $gpmName



#             Check for folder to put GPO in

                if (!(Test-Path $strLocation))


                                md $strLocation


#             Log some info.

                echo $gpmName >> $Logs

                echo $gpmName

                Export-SDMgpo -Name $gpmName  -location $strLocation
-Description $gpmName >> $Logs







Kevin Gay

Desktop Administrator

Cherokee Nation Enterprises


Catoosa, OK 74015


Other related posts: